Offset() public method

Adjusts the location of this rectangle by the specified amount.

public Offset ( Point pos ) : void
pos Point
return void
Ejemplo n.º 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();
		}
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
        protected void PaintTransparentBackground(Graphics g, Rectangle clipRect)
        {
            if ((this.Parent != null))
            {
                clipRect.Offset(this.Location);
                PaintEventArgs e     = new PaintEventArgs(g, clipRect);
                GraphicsState  state = g.Save();
                try
                {
                    g.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);
                    this.InvokePaintBackground(this.Parent, e);
                    this.InvokePaint(this.Parent, e);
                }

                finally
                {
                    g.Restore(state);
                    clipRect.Offset(-this.Location.X, -this.Location.Y);
                }
            }
            else
            {
                LinearGradientBrush backBrush = new LinearGradientBrush(this.Bounds, SystemColors.ControlLightLight, SystemColors.ControlLight, LinearGradientMode.Vertical);
                g.FillRectangle(backBrush, this.Bounds);
                backBrush.Dispose();
            }
        }
        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();
        }
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 更新矩形
 /// </summary>
 /// <param name="rect">原始矩形</param>
 /// <param name="dx">水平移动量</param>
 /// <param name="dy">垂直移动量</param>
 /// <returns>处理后的矩形</returns>
 public System.Drawing.Rectangle UpdateRectangle(System.Drawing.Rectangle rect, int dx, int dy)
 {
     // 中间
     if (intDragStyle == -1)
     {
         rect.Offset(dx, dy);
     }
     // 左边
     if (intDragStyle == 0 || intDragStyle == 7 || intDragStyle == 6)
     {
         rect.Offset(dx, 0);
         rect.Width = rect.Width - dx;
     }
     // 顶边
     if (intDragStyle == 0 || intDragStyle == 1 || intDragStyle == 2)
     {
         rect.Offset(0, dy);
         rect.Height = rect.Height - dy;
     }
     // 右边
     if (intDragStyle == 2 || intDragStyle == 3 || intDragStyle == 4)
     {
         rect.Width = rect.Width + dx;
     }
     // 底边
     if (intDragStyle == 4 || intDragStyle == 5 || intDragStyle == 6)
     {
         rect.Height = rect.Height + dy;
     }
     return(rect);
 }
Ejemplo n.º 8
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);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 渲染标签
        /// </summary>
        /// <param name="drawArgs">绘制参数</param>
        /// <param name="x">标签X位置</param>
        /// <param name="y">标签Y位置</param>
        /// <param name="buttonHeight">按钮高度</param>
        /// <param name="selected">是否被选中</param>
        /// <param name="anchor">菜单位置</param>
        public void RenderLabel(DrawArgs drawArgs, int x, int y, int buttonHeight, bool selected, MenuAnchor anchor)
        {
            if (selected)
            {
                if (buttonHeight == curSize)
                {
                    alpha += alphaStep;
                    if (alpha > 255)
                    {
                        alpha = 255;
                    }
                }
            }
            else
            {
                alpha -= alphaStep;
                if (alpha < 0)
                {
                    alpha = 0;
                    return;
                }
            }

            int halfWidth = (int)(SelectedSize * 0.75);
            int label_x   = x - halfWidth + 1;
            int label_y   = (int)(y + SelectedSize) + 1;

            DrawTextFormat format = DrawTextFormat.NoClip | DrawTextFormat.Center | DrawTextFormat.WordBreak;

            if (anchor == MenuAnchor.Bottom)
            {
                format |= DrawTextFormat.Bottom;
                label_y = y - 202;
            }

            Rectangle rect = new System.Drawing.Rectangle(label_x, label_y, (int)halfWidth * 2, 200);

            if (rect.Right > drawArgs.ScreenWidth)
            {
                rect = Rectangle.FromLTRB(rect.Left, rect.Top, drawArgs.ScreenWidth, rect.Bottom);
            }

            drawArgs.ToolbarFont.DrawText(null, Description, rect, format, black & 0xffffff + (alpha << 24));

            rect.Offset(2, 0);
            drawArgs.ToolbarFont.DrawText(null, Description, rect, format, black & 0xffffff + (alpha << 24));

            rect.Offset(0, 2);
            drawArgs.ToolbarFont.DrawText(null, Description, rect, format, black & 0xffffff + (alpha << 24));

            rect.Offset(-2, 0);
            drawArgs.ToolbarFont.DrawText(null, Description, rect, format, black & 0xffffff + (alpha << 24));

            rect.Offset(1, -1);
            drawArgs.ToolbarFont.DrawText(null, Description, rect, format, white & 0xffffff + (alpha << 24));
        }
Ejemplo n.º 10
0
        public override void DrawDayHeader(System.Drawing.Graphics g, System.Drawing.Rectangle rect, DateTime date)
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }

            System.Drawing.Rectangle rHeader = rect;
            rHeader.Height += 2;

            if (date.Date.Equals(DateTime.Now.Date))
            {
                rHeader.Width += 1;
                HeaderHot.DrawBackground(g, rHeader);
            }
            else
            {
                rHeader.X += 1;
                HeaderNormal.DrawBackground(g, rHeader);
            }

            using (StringFormat format = new StringFormat())
            {
                format.Alignment     = StringAlignment.Center;
                format.FormatFlags   = StringFormatFlags.NoWrap;
                format.LineAlignment = StringAlignment.Center;

                using (StringFormat formatdd = new StringFormat())
                {
                    formatdd.Alignment     = StringAlignment.Near;
                    formatdd.FormatFlags   = StringFormatFlags.NoWrap;
                    formatdd.LineAlignment = StringAlignment.Center;

                    g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

                    //get short dayabbr. if narrow dayrect
                    string sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek);
                    if (rect.Width < 105)
                    {
                        sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);
                    }

                    rect.Offset(2, 1);

                    using (Font fntDay = new Font("Tahoma", 8))
                        g.DrawString(sTodaysName, fntDay, SystemBrushes.WindowText, rect, format);

                    rect.Offset(-2, -1);

                    using (Font fntDayDate = new Font("Tahoma", 9, FontStyle.Bold))
                        g.DrawString(date.ToString(" d"), fntDayDate, SystemBrushes.WindowText, rect, formatdd);
                }
            }
        }
Ejemplo n.º 11
0
        public override void DrawDayHeader(System.Drawing.Graphics g, System.Drawing.Rectangle rect, DateTime date)
        {
            StringFormat m_Format = new StringFormat();

            m_Format.Alignment     = StringAlignment.Center;
            m_Format.FormatFlags   = StringFormatFlags.NoWrap;
            m_Format.LineAlignment = StringAlignment.Center;

            StringFormat m_Formatdd = new StringFormat();

            m_Formatdd.Alignment     = StringAlignment.Near;
            m_Formatdd.FormatFlags   = StringFormatFlags.NoWrap;
            m_Formatdd.LineAlignment = StringAlignment.Center;

            using (SolidBrush brush = new SolidBrush(this.BackColor))
                g.FillRectangle(brush, rect);

            using (Pen aPen = new Pen(Color.FromArgb(225, 200, 205))) // want light pink
                g.DrawLine(aPen, rect.Left, rect.Top + (int)rect.Height / 2, rect.Right, rect.Top + (int)rect.Height / 2);

            using (Pen aPen = new Pen(Color.Crimson))  // want Crimson or light crimson
                g.DrawRectangle(aPen, rect);

            Rectangle topPart = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, (int)(rect.Height / 2) - 1);
            Rectangle lowPart = new Rectangle(rect.Left + 1, rect.Top + (int)(rect.Height / 2) + 1, rect.Width - 1, (int)(rect.Height / 2) - 1);

            using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(236, 118, 138), Color.FromArgb(236, 111, 131) /*Color.FromArgb(236, 209, 209)*/, LinearGradientMode.Vertical)) // light pink
                g.FillRectangle(aGB, topPart);

            using (LinearGradientBrush aGB = new LinearGradientBrush(lowPart, Color.FromArgb(220, 83, 106), Color.FromArgb(215, 77, 101), LinearGradientMode.Vertical)) // darker pink
                g.FillRectangle(aGB, lowPart);

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            //get short dayabbr. if narrow dayrect
            string sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek);

            if (rect.Width < 105)
            {
                sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);
            }

            rect.Offset(2, 1);

            using (Font fntDay = new Font("Segoe UI", 8))
                g.DrawString(sTodaysName, fntDay, SystemBrushes.WindowText, rect, m_Format);

            rect.Offset(-2, -1);

            //using (Font fntDayDate = new Font("Segoe UI", 9, FontStyle.Bold))
            //    g.DrawString(date.ToString(" d"), fntDayDate, SystemBrushes.WindowText, rect, m_Formatdd);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Refreshes the shape
        /// </summary>
        public override void Invalidate()
        {
            if (Site == null)
            {
                return;
            }
            if (Connectors == null)
            {
                return;
            }

            // Invalidate the shape mRectangle, pay attention on scroll position and zoom
            RectangleF r = this.Rectangle;

            r.Inflate(+3, +3);             // padding for selection frame.

            System.Drawing.Rectangle r2 = System.Drawing.Rectangle.Round(r);
            r2.Offset(Site.AutoScrollPosition.X, Site.AutoScrollPosition.Y);

            r2 = Site.ZoomRectangle(r2);
            r2.Inflate(2, 2);

            Site.InvalidateRectangle(r2);

            // Invalidate each connector
            foreach (Connector c in Connectors)
            {
                c.Invalidate();

                if (Tracker != null)
                {
                    foreach (Connection n in c.Connections)
                    {
                        n.Invalidate();
                    }
                }
            }

            // Invalidate tracker
            if (Tracker != null)
            {
                RectangleF a = Tracker.Grip(new Point(-1, -1));
                RectangleF b = Tracker.Grip(new Point(+1, +1));
                r2 = System.Drawing.Rectangle.Round(RectangleF.Union(a, b));
                r2.Offset(Site.AutoScrollPosition.X, Site.AutoScrollPosition.Y);
                r2 = Site.ZoomRectangle(r2);
                r2.Inflate(2, 2);

                Site.InvalidateRectangle(r2);
            }
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 15
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();
            }
        }
Ejemplo n.º 16
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();
      }
Ejemplo n.º 17
0
            /// <summary>
            /// The real work of drawing the tree is done in this method
            /// </summary>
            /// <param name="g"></param>
            /// <param name="r"></param>
            public override void Render(System.Drawing.Graphics g, System.Drawing.Rectangle r)
            {
                this.DrawBackground(g, r);

                Branch br = this.Branch;

                if (this.IsShowLines)
                {
                    this.DrawLines(g, r, this.LinePen, br);
                }

                if (br.CanExpand)
                {
                    Rectangle r2 = r;
                    r2.Offset((br.Level - 1) * PIXELS_PER_LEVEL, 0);
                    r2.Width = PIXELS_PER_LEVEL;

                    this.DrawExpansionGlyph(g, r2, br.IsExpanded);
                }

                int indent = br.Level * PIXELS_PER_LEVEL;

                r.Offset(indent, 0);
                r.Width -= indent;

                this.DrawImageAndText(g, r);
            }
 /// <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);
 }
Ejemplo n.º 19
0
        /// <summary>
        /// 绘制页面框架
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">图形绘制对象</param>
        /// <param name="Focused">该页是否是当前页</param>
        /// <param name="FillBackGround">是否填充背景</param>
        protected void DrawPageFrame(
            PrintPage myPage,
            System.Drawing.Graphics g,
            bool Focused,
            bool FillBackGround)
        {
            if (myPage == null || myPages.Contains(myPage) == false)
            {
                return;
            }

            System.Drawing.Rectangle bounds = myPage.ClientBounds;
            bounds.Offset(this.AutoScrollPosition);

            PageFrameDrawer pfdraw = new PageFrameDrawer();

            pfdraw.BackColor = this.PageBackColor;
            #region bwy :
            pfdraw.DrawTopMargin    = this.drawtopmargin;
            pfdraw.DrawBottomMargin = this.drawbottommargin;
            #endregion bwy :
            pfdraw.DrawPageFrame(
                bounds,
                this.myClientMargins,
                g,
                System.Drawing.Rectangle.Empty,
                Focused,
                FillBackGround);
        }
Ejemplo n.º 20
0
        public override void OnRender(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, Foreground, rect, Format);
#else
            g.DrawString(ToolTipText, ToolTipFont, TooltipForeground, rect, ToolTipFormat);
#endif
        }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
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;
            }
        }
Ejemplo n.º 23
0
 protected void sip_EnabledChanged(object sender, EventArgs e)
 {
     if (this.sip.Enabled)
     {
         SenseListControl.ISenseListItem IItem = this.senseListCtrl.FocusedItem;
         if (IItem != null)
         {
             System.Drawing.Rectangle r = IItem.ClientRectangle;
             r.Offset(0, this.senseListCtrl.Bounds.Top);
             if (IItem is SensePanelTextboxItem)
             {
                 if (r.Bottom > this.sip.VisibleDesktop.Height)
                 {
                     this._sipOffset = Math.Abs(this.sip.VisibleDesktop.Height - r.Bottom);
                     this.senseListCtrl.ScrollList(-this._sipOffset);
                     this.senseListCtrl.Invalidate();
                 }
             }
         }
     }
     else
     {
         if (!this._sipOffset.Equals(0))
         {
             this.senseListCtrl.ScrollList(this._sipOffset);
             this.senseListCtrl.Invalidate();
         }
         this._sipOffset = 0;
     }
 }
Ejemplo n.º 24
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);
				}
			}
		}
Ejemplo n.º 25
0
        /// <summary>
        /// Paints the image on the button.
        /// </summary>
        /// <param name="e"></param>

        private void paint_Image(PaintEventArgs e)
        {
            if (e == null)
            {
                return;
            }
            if (e.Graphics == null)
            {
                return;
            }
            Image image = GetCurrentImage(btnState);

            if (image != null)
            {
                Graphics g = e.Graphics;
                System.Drawing.Rectangle rect = GetImageDestinationRect();

                if ((btnState == BtnState.Pushed) && (_OffsetPressedContent))
                {
                    rect.Offset(1, 1);
                }
                if (this.StretchImage)
                {
                    g.DrawImage(image, rect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
                }
                else
                {
                    System.Drawing.Rectangle r = GetImageDestinationRect();
                    //g.DrawImage(image,rect.Left,rect.Top);
                    g.DrawImage(image, rect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
                }
                paint_ImageBorder(g, rect);
            }
        }
Ejemplo n.º 26
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);
				}
			}
		}
Ejemplo n.º 27
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
        }
Ejemplo n.º 28
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);
        }
Ejemplo n.º 29
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();
        }
Ejemplo n.º 30
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);
        }
Ejemplo n.º 31
0
 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);
 }
Ejemplo n.º 32
0
            /// <summary>
            /// The real work of drawing the tree is done in this method
            /// </summary>
            /// <param name="g"></param>
            /// <param name="r"></param>
            public override void Render(System.Drawing.Graphics g, System.Drawing.Rectangle r)
            {
                this.DrawBackground(g, r);

                Branch br = this.Branch;

                if (this.IsShowLines)
                {
                    using (Pen p = this.GetLinePen())
                        this.DrawLines(g, r, p, br);
                }

                if (br.CanExpand)
                {
                    Rectangle r2 = r;
                    r2.Offset((br.Level - 1) * PIXELS_PER_LEVEL, 0);
                    r2.Width = PIXELS_PER_LEVEL;

                    VisualStyleElement element = VisualStyleElement.TreeView.Glyph.Closed;
                    if (br.IsExpanded)
                    {
                        element = VisualStyleElement.TreeView.Glyph.Opened;
                    }
                    VisualStyleRenderer renderer = new VisualStyleRenderer(element);
                    renderer.DrawBackground(g, r2);
                }

                int indent = br.Level * PIXELS_PER_LEVEL;

                r.Offset(indent, 0);
                r.Width -= indent;

                this.DrawImageAndText(g, r);
            }
Ejemplo n.º 33
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);
        }
Ejemplo n.º 34
0
        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;
        }
Ejemplo n.º 35
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);
		}
Ejemplo n.º 36
0
        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];
        }
Ejemplo n.º 37
0
        public override void OnRender(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 * 2, st.Height + TextPadding.Height);
            rect.Offset(Offset.X, Offset.Y);

            g.DrawLine(Stroke, Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y, rect.X + Radius / 2, rect.Y + rect.Height - Radius / 2);

            DrawRoundRectangle(g, Stroke, rect.X, rect.Y, rect.Width, rect.Height, Radius);

            if (Format.Alignment == StringAlignment.Near)
            {
                rect.Offset(TextPadding.Width, 3);
            }
            g.DrawString(Marker.ToolTipText, Font, Foreground, rect, Format);
        }
Ejemplo n.º 38
0
        public virtual 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);

            g.DrawLine(Stroke, Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y, rect.X, rect.Y + rect.Height / 2);

            g.FillRectangle(Fill, rect);
            g.DrawRectangle(Stroke, rect);

#if PocketPC
            rect.Offset(0, (rect.Height - st.Height) / 2);
#endif

            g.DrawString(Marker.ToolTipText, Font, Foreground, rect, Format);
        }
Ejemplo n.º 39
0
        protected virtual void TransformPaint(PaintEventArgs e, SimpleRectangleTransform trans)
        {
            if (trans == null)
            {
                return;
            }

            System.Drawing.Rectangle rect = e.ClipRectangle;
            rect.Offset(-1, -1);
            rect.Width  += 2;
            rect.Height += 2;
            rect         = System.Drawing.Rectangle.Intersect(trans.SourceRect, rect);
            if (rect.IsEmpty)
            {
                return;
            }

            System.Drawing.RectangleF rectf = trans.TransformRectangleF(
                (float)rect.Left,
                (float)rect.Top,
                (float)rect.Width,
                (float)rect.Height);
            rect.X      = (int)Math.Floor((double)rectf.Left);
            rect.Y      = (int)Math.Floor((double)rectf.Top);
            rect.Width  = (int)System.Math.Ceiling((double)rectf.Width);
            rect.Height = (int)System.Math.Ceiling((double)rectf.Height);

            e.Graphics.PageUnit = this.intGraphicsUnit;
            e.Graphics.ResetTransform();

            e.Graphics.ScaleTransform(this.fXZoomRate, this.fYZoomRate);
            double rate = this.ClientToViewXRate * (double)this.fXZoomRate;

            e.Graphics.TranslateTransform(
                (float)((double)trans.SourceRect.Left * rate - (double)trans.DescRectF.X),
                (float)((double)trans.SourceRect.Top * rate - (double)trans.DescRectF.Y));

            if (trans.XZoomRate < 1f)
            {
                rect.Width += (int)System.Math.Ceiling((double)(1f / trans.XZoomRate));
            }

            if (trans.YZoomRate < 1f)
            {
                rect.Height += (int)System.Math.Ceiling((double)(1f / trans.YZoomRate));
            }

            System.Windows.Forms.PaintEventArgs e2 =
                new System.Windows.Forms.PaintEventArgs(
                    e.Graphics,
                    rect);

            e2.Graphics.ResetClip();
            e2.Graphics.SetClip(new Rectangle(rect.Left, rect.Top, rect.Width + 2, rect.Height + 2));

            OnViewPaint(e2, trans);
        }
Ejemplo n.º 40
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;
		}
Ejemplo n.º 41
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);
            }
        }
Ejemplo n.º 42
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);
        }
Ejemplo n.º 43
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;
            }
        }
        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();
        }
        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();
        }
Ejemplo n.º 46
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (myImage != null)
            {
                System.Drawing.Point     sp       = this.AutoScrollPosition;
                System.Drawing.Rectangle rect     = this.ImageBounds;
                System.Drawing.Point     ip       = rect.Location;
                System.Drawing.Rectangle ClipRect = e.ClipRectangle;
                ClipRect.Offset(0 - sp.X, 0 - sp.Y);
                rect = System.Drawing.Rectangle.Intersect(ClipRect, rect);
                if (rect.Width > 0 || rect.Height > 0)
                {
                    e.Graphics.DrawImage(myImage,
                                         new System.Drawing.Rectangle
                                             (rect.Left + sp.X,
                                             rect.Top + sp.Y,
                                             rect.Width,
                                             rect.Height),
                                         new System.Drawing.Rectangle(rect.Left - ip.X, rect.Top - ip.Y, rect.Width, rect.Height),
                                         System.Drawing.GraphicsUnit.Pixel);
//					rect = this.ImageBounds ;
//					rect.Offset( - sp.X , - sp.Y );
//					if( this.Focused )
//						System.Windows.Forms.ControlPaint.DrawFocusRectangle( e.Graphics , rect );
                }
                //string strText = "宽:" + myImage.Size.Width + " 高:" + myImage.Size.Height + " 格式:" + myImage.PixelFormat ;
            }
            if (this.BehaviorStyle == XPictureBoxBehaviorStyle.DragSelect)
            {
                using (ReversibleDrawer drawer = new ReversibleDrawer(e.Graphics))
                {
                    drawer.PenColor  = Color.White;
                    drawer.PenStyle  = PenStyle.PS_SOLID;
                    drawer.LineWidth = 1;

                    Rectangle rect2 = this.SelectionBounds;
                    if (rect2.IsEmpty == false)
                    {
                        rect2.Offset(this.AutoScrollPosition.X, this.AutoScrollPosition.Y);
                        rect2.Offset(this.ImageBounds.Location);
                        drawer.DrawRectangle(rect2);
                    }
                    if (myLastPoint != null)
                    {
                        drawer.DrawLine(0, myLastPoint.Y, this.ClientSize.Width, myLastPoint.Y);
                        drawer.DrawLine(myLastPoint.X, 0, myLastPoint.X, this.ClientSize.Height);
                        myLastPoint = null;
                    }
                }
            }
            base.OnPaint(e);
        }
Ejemplo n.º 47
0
 protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
 {
     System.Drawing.Point point = e.Location;
     for (int i = 0; i < TabCount; i++)
     {
         System.Drawing.Rectangle rectangle = GetTabRect(i);
         rectangle.Offset(_LeftSpacing, 0);
         if (rectangle.Contains(point) && (SelectedIndex != i))
         {
             allowNextSelection = true;
             SelectedIndex      = i;
             return;
         }
     }
 }
Ejemplo n.º 48
0
        private void MoveCenterOfWindowTo(double x, double y)
        {
            var workingArea = SWF.Screen.PrimaryScreen.WorkingArea;

            var workingTop    = (int)(workingArea.Top * this.VerticalDpiScale);
            var workingBottom = (int)(workingArea.Bottom * this.VerticalDpiScale);
            var workingLeft   = (int)(workingArea.Left * this.HorizontalDpiScale);
            var workingRight  = (int)(workingArea.Right * this.HorizontalDpiScale);

            var candidatePosition =
                new SD.Rectangle(
                    (int)(x - (this.AdjustedWidth / 2)),
                    (int)(y - (this.AdjustedHeight / 2)),
                    (int)this.AdjustedWidth,
                    (int)this.AdjustedHeight);

            if (candidatePosition.Top < workingTop)
            {
                candidatePosition.Offset(0, workingTop - candidatePosition.Top);
            }
            if (candidatePosition.Bottom > workingBottom)
            {
                candidatePosition.Offset(0, workingBottom - candidatePosition.Bottom);
            }
            if (candidatePosition.Left < workingLeft)
            {
                candidatePosition.Offset(workingLeft - candidatePosition.Left, 0);
            }
            if (candidatePosition.Right > workingRight)
            {
                candidatePosition.Offset(workingRight - candidatePosition.Right, 0);
            }

            this.AdjustedTop  = candidatePosition.Top;
            this.AdjustedLeft = candidatePosition.Left;
        }
Ejemplo n.º 49
0
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)
        {
            DataRowView drv = source.List[rowNum] as DataRowView;
            Image       img = null;

            if (drv != null)
            {
                img = imageMap[drv[this.MappingName]] as Image;
            }
            g.FillRectangle(backBrush, bounds);
            bounds.Offset(2, 1);
            if (img != null)
            {
                g.DrawImageUnscaled(img, bounds);
            }
        }
Ejemplo n.º 50
0
        override protected void DrawToolTip(Graphics g, GMapMarker m, int x, int y)
        {
            GraphicsState s = g.Save();

            g.SmoothingMode = SmoothingMode.AntiAlias;

            System.Drawing.Size      st   = g.MeasureString(m.ToolTipText, TooltipFont).ToSize();
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(x, y, st.Width + Control.TooltipTextPadding.Width, st.Height + Control.TooltipTextPadding.Height);
            rect.Offset(m.ToolTipOffset.X, m.ToolTipOffset.Y);

            g.DrawLine(TooltipPen, x, y, rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
            g.FillRectangle(TooltipBackground, rect);
            g.DrawRectangle(TooltipPen, rect);
            g.DrawString(m.ToolTipText, TooltipFont, Brushes.Navy, rect, TooltipFormat);

            g.Restore(s);
        }
Ejemplo n.º 51
0
        internal void DrawControl(System.Drawing.Graphics g)
        {
            System.Drawing.Brush brush;

            if (!Visible)
            {
                return;
            }
            System.Drawing.Rectangle rectangle1 = ClientRectangle;
            System.Drawing.Rectangle rectangle2 = DisplayRectangle;
            if (mBackColor == System.Drawing.Color.Transparent)
            {
                brush = new System.Drawing.SolidBrush(Parent.BackColor);
            }
            else
            {
                brush = new System.Drawing.SolidBrush(mBackColor);
            }
            g.FillRectangle(brush, rectangle1);
            brush.Dispose();
            System.Drawing.Size size = System.Windows.Forms.SystemInformation.Border3DSize;
            int i1 = size.Width;

            System.Drawing.Pen pen = new System.Drawing.Pen(_BorderColor);
            rectangle2.Inflate(i1, i1);
            g.DrawRectangle(pen, rectangle2);
            pen.Dispose();
            for (int i2 = 0; i2 < TabCount; i2++)
            {
                DrawTab(g, TabPages[i2], i2);
            }
            if (SelectedTab != null)
            {
                System.Windows.Forms.TabPage tabPage = SelectedTab;
                //tabPage.BackColor;
                pen = new System.Drawing.Pen(_TagPageSelectedColor);
                rectangle2.Offset(1, 1);
                rectangle2.Width  -= 2;
                rectangle2.Height -= 2;
                g.DrawRectangle(pen, rectangle2);
                rectangle2.Width--;
                rectangle2.Height--;
                g.DrawRectangle(pen, rectangle2);
                pen.Dispose();
            }
        }
Ejemplo n.º 52
0
        public override void OnRender(Graphics g)
        {
            System.Drawing.Size      st   = new System.Drawing.Size(330, 260);
            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 * 20, rect.Y + rect.Height, rect.X + Radius * 20, rect.Y + rect.Height + Radius * 20);
                objGP.AddLine(rect.X + Radius * 20, rect.Y + rect.Height + Radius * 20, rect.X + Radius * 20 + 10, 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);
            }

            try
            {
                SiteBean          sb      = tag as SiteBean;
                InfoWindowContent content = new InfoWindowContent();
                content.SetInfoWindContent(sb.SiteCode, sb.SiteName, sb.SiteStatus, sb.SiteType, sb.ObsType, sb.Place, sb.FaultCode, sb.ObsUnit, sb.SiteSituation);
                Bitmap bit = new Bitmap(content.Width + 20, content.Height + 20);
                content.DrawToBitmap(bit, content.ClientRectangle);

                Rectangle r = rect;
                r.X = r.X + 4;
                r.Y = r.Y + 4;
                g.DrawImageUnscaled(bit, r);
            }
            catch
            { }
        }
        private Task <RetrieveResult> FindFaceEyesIrisAsync()
        {
            return(Task <RetrieveResult> .Run(() =>
            {
                detector.DetectFace(grayFrame, out FaceRetrieveResult face, out EyeRetrieveResult eye);
                if (!face.HasFace)
                {
                    return null;
                }
                bool hasLeftPupil = false;
                CIRCLE leftPupil = default;
                if (eye.HasLeftEye)
                {
                    RECT leftEye = eye.LeftEye;
                    int offsety = (int)(leftEye.Height * 0.2);
                    int offsetx = (int)(leftEye.Width * 0.1);
                    leftEye.Offset(offsetx, offsety);
                    leftEye.Height = leftEye.Height - offsety - offsety;

                    leftPupil = Iris.SearchInnerBoundary(grayBytes, img_width, img_height, leftEye.Left, leftEye.Top, leftEye.Right, leftEye.Bottom);
                }
                bool hasRightPupil = false;
                CIRCLE rightPupil = default;
                if (eye.HasRightEye)
                {
                    RECT rightEye = eye.RightEye;
                    int offsety = (int)(rightEye.Height * 0.2);
                    int offsetx = (int)(rightEye.Width * 0.1);
                    rightEye.Offset(-offsetx, offsety);
                    rightEye.Height = rightEye.Height - offsety - offsety;
                    rightPupil = Iris.SearchInnerBoundary(grayBytes, img_width, img_height, rightEye.Left, rightEye.Top, rightEye.Right, rightEye.Bottom);
                }
                return new RetrieveResult()
                {
                    Face = face,
                    Eye = eye,
                    Pupil = new PupilRetrieveResult(hasLeftPupil, leftPupil, hasRightPupil, rightPupil),
                };
            }));
        }
Ejemplo n.º 54
0
 /// <summary>
 /// Calculates the rectangular region used for image display.
 /// </summary>
 /// <returns>returns the rectangular region used to display the image</returns>
 private System.Drawing.Rectangle GetImageDestinationRect()
 {
     System.Drawing.Rectangle rect  = new System.Drawing.Rectangle(0, 0, 0, 0);
     System.Drawing.Image     image = GetCurrentImage(this.btnState);
     if (image != null)
     {
         if (this.StretchImage)
         {
             rect.Width  = this.Width;
             rect.Height = this.Height;
         }
         else
         {
             rect.Width  = image.Width;
             rect.Height = image.Height;
             System.Drawing.Rectangle drect = new System.Drawing.Rectangle(0, 0, this.Width, this.Height);
             drect.Inflate(-this.Padding, -this.Padding);
             System.Drawing.Point pt = Calculate_LeftEdgeTopEdge(this.ImageAlign, drect, image.Width, image.Height);
             rect.Offset(pt);
         }
     }
     return(rect);
 }
Ejemplo n.º 55
0
        /// <summary>
        /// 绘制页面框架
        /// </summary>
        /// <param name="myPage">页面对象</param>
        /// <param name="g">图形绘制对象</param>
        /// <param name="Focused">该页是否是当前页</param>
        /// <param name="FillBackGround">是否填充背景</param>
        protected void DrawPageFrame(
            PrintPage myPage,
            System.Drawing.Graphics g,
            System.Drawing.Rectangle ClipRectangle,
            bool FillBackGround)
        {
            if (myPage == null || _Pages.Contains(myPage) == false)
            {
                return;
            }
            System.Drawing.Rectangle bounds = myPage.ClientBounds;
            bounds.Offset(this.AutoScrollPosition);
            // 绘制页面阴影
            //int ShadowSize = 5;
            //g.FillRectangle(System.Drawing.Brushes.Black, bounds.Right - 1 , bounds.Top + ShadowSize, ShadowSize, bounds.Height-1);
            //g.FillRectangle(System.Drawing.Brushes.Black , bounds.Left + ShadowSize, bounds.Bottom - 1 , bounds.Width-1, ShadowSize);

            //System.Drawing.Rectangle ShadowRect = bounds;
            //ShadowRect.Offset(10 , 10 );
            //using (System.Drawing.Pen p = new System.Drawing.Pen( System.Drawing.Color.Gray , 10 ))
            //{
            //    g.DrawRectangle(p, ShadowRect);
            //}
            PageFrameDrawer drawer = new PageFrameDrawer();

            drawer.BorderWidth = 1;
            drawer.Bounds      = bounds;
            drawer.Margins     = myPage.ClientMargins;
            if (myPage == this.CurrentPage)
            {
                if (this.Enabled)                                                            // info.Enabled )
                {
                    drawer.BorderColor = System.Drawing.ColorTranslator.FromHtml("#EEAA57"); // System.Drawing.Color.Red;
                    drawer.BorderWidth = 3;
                }
                else
                {
                    drawer.BorderColor = System.Drawing.Color.LightGray;
                    drawer.BorderWidth = 3;
                }
            }
            else
            {
                drawer.BorderWidth = 3;
                drawer.BorderColor = System.Drawing.Color.Black;
            }
            drawer.BackColor = FillBackGround ? this.PageBackColor : System.Drawing.Color.Transparent;

            //this.FixedBackground = false;


            drawer.DrawPageFrame(g, ClipRectangle);



            //XDesignerDrawer.PageFrameDrawer.DrawPageFrame(
            //    bounds ,
            //    this.myClientMargins ,
            //    g ,
            //    System.Drawing.Rectangle.Empty ,
            //    Focused ,
            //    FillBackGround ? this.PageBackColor : System.Drawing.Color.Transparent );
        }
Ejemplo n.º 56
0
        public override void DrawDayHeader(System.Drawing.Graphics g, System.Drawing.Rectangle rect, DateTime date)
        {
            StringFormat m_Format = new StringFormat();

            m_Format.Alignment     = StringAlignment.Center;
            m_Format.FormatFlags   = StringFormatFlags.NoWrap;
            m_Format.LineAlignment = StringAlignment.Center;

            StringFormat m_Formatdd = new StringFormat();

            m_Formatdd.Alignment     = StringAlignment.Near;
            m_Formatdd.FormatFlags   = StringFormatFlags.NoWrap;
            m_Formatdd.LineAlignment = StringAlignment.Center;

            using (SolidBrush brush = new SolidBrush(this.BackColor))
                g.FillRectangle(brush, rect);

            using (Pen aPen = new Pen(Color.FromArgb(205, 219, 238)))
                g.DrawLine(aPen, rect.Left, rect.Top + (int)rect.Height / 2, rect.Right, rect.Top + (int)rect.Height / 2);

            using (Pen aPen = new Pen(Color.FromArgb(141, 174, 217)))
                g.DrawRectangle(aPen, rect);

            Rectangle topPart = new Rectangle(rect.Left + 1, rect.Top + 1, rect.Width - 2, (int)(rect.Height / 2) - 1);
            Rectangle lowPart = new Rectangle(rect.Left + 1, rect.Top + (int)(rect.Height / 2) + 1, rect.Width - 1, (int)(rect.Height / 2) - 1);

            using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(228, 236, 246), Color.FromArgb(214, 226, 241), LinearGradientMode.Vertical))
                g.FillRectangle(aGB, topPart);

            using (LinearGradientBrush aGB = new LinearGradientBrush(lowPart, Color.FromArgb(194, 212, 235), Color.FromArgb(208, 222, 239), LinearGradientMode.Vertical))
                g.FillRectangle(aGB, lowPart);

            if (date.Date.Equals(DateTime.Now.Date))
            {
                topPart.Inflate((int)(-topPart.Width / 4 + 1), 1); //top left orange area
                topPart.Offset(rect.Left - topPart.Left + 1, 1);
                topPart.Inflate(1, 0);
                using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(247, 207, 114), Color.FromArgb(251, 230, 148), LinearGradientMode.Horizontal))
                {
                    topPart.Inflate(-1, 0);
                    g.FillRectangle(aGB, topPart);
                }

                topPart.Offset(rect.Right - topPart.Right, 0);        //top right orange
                topPart.Inflate(1, 0);
                using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(251, 230, 148), Color.FromArgb(247, 207, 114), LinearGradientMode.Horizontal))
                {
                    topPart.Inflate(-1, 0);
                    g.FillRectangle(aGB, topPart);
                }

                using (Pen aPen = new Pen(Color.FromArgb(128, 240, 154, 30))) //center line
                    g.DrawLine(aPen, rect.Left, topPart.Bottom - 1, rect.Right, topPart.Bottom - 1);

                topPart.Inflate(0, -1);
                topPart.Offset(0, topPart.Height + 1); //lower right
                using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.BackwardDiagonal))
                    g.FillRectangle(aGB, topPart);

                topPart.Offset(rect.Left - topPart.Left + 1, 0); //lower left
                using (LinearGradientBrush aGB = new LinearGradientBrush(topPart, Color.FromArgb(240, 157, 33), Color.FromArgb(250, 226, 142), LinearGradientMode.ForwardDiagonal))
                    g.FillRectangle(aGB, topPart);
                using (Pen aPen = new Pen(Color.FromArgb(238, 147, 17)))
                    g.DrawRectangle(aPen, rect);
            }

            g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            //get short dayabbr. if narrow dayrect
            string sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek);

            if (rect.Width < 105)
            {
                sTodaysName = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedDayName(date.DayOfWeek);
            }

            rect.Offset(2, 1);

            using (Font fntDay = new Font("Segoe UI", 8))
                g.DrawString(sTodaysName, fntDay, SystemBrushes.WindowText, rect, m_Format);

            rect.Offset(-2, -1);

            using (Font fntDayDate = new Font("Segoe UI", 9, FontStyle.Bold))
                g.DrawString(date.ToString(" d"), fntDayDate, SystemBrushes.WindowText, rect, m_Formatdd);
        }
Ejemplo n.º 57
0
        /// <summary>
        /// Rendering method
        /// </summary>
        /// <param name="g">Graphic to render</param>
        public override void OnRender(Graphics g)
        {
            if (_geo != null)
            {
                String imgpath       = _daddy.GetResourcesDataPath() + Path.DirectorySeparatorChar + "Img";
                String imgpath_clean = imgpath.Replace("\\", "/");


                String nameHtml = "";
                if (_geo._Available.ToLower() == "true")
                {
                    nameHtml = _geo._Name.Replace("'", "&#146;");
                }
                else
                {
                    nameHtml = "<span style=\"text-decoration:line-through;\">" + _geo._Name.Replace("'", " ") + "</span>";
                }

                String           stats = "";
                OfflineCacheData ocd   = _geo._Ocd;
                if ((ocd != null) && (ocd.HasStats()))
                {
                    // On a des stats
                    double rating;
                    rating = (_daddy._bUseGCPopularity) ? ocd._dRatingSimple : ocd._dRating;
                    if (rating >= 0)
                    {
                        stats = "	<tr><td><img width=16 height=16 src='"+ imgpath_clean + "/Fav.png'>" + ocd._iNbFavs.ToString() +
                                ",&nbsp;" + _daddy.GetTranslator().GetString("LVRating") + ":&nbsp;" + "</td>" +
                                "		<td>"+
                                "<img src='" + imgpath_clean + "/Ratios/" + "ratio_" + ((int)(ocd._dRating * 100.0)).ToString() + ".png'>" + rating.ToString("0.0%").ToString() + "</td></tr>";
                    }
                    else if (ocd._iNbFavs > 0)
                    {
                        stats = "	<tr><td><img width=16 height=16 src='"+ imgpath_clean + "/Fav.png'>" + ocd._iNbFavs.ToString() + "</td>" +
                                "		<td>&nbsp;</td></tr>";
                    }
                }

                //String theType = "		<img width=16 height=16 src='" + imgpath_clean + "/Type/" + _geo._Type + ".gif'>";
                String theType = "		<img src='"+ imgpath_clean + "/TypeCat/" + _daddy._geocachingConstants.GetDicoTypeSmallIcon()[_geo._Type] + ".png'>";

                if (MyTools.InsensitiveContainsInStringList(GeocachingConstants.GetSupportedCacheTypes(), _geo._Type) == false)
                {
                    theType = "		<img width=16 height=16 src='"+ imgpath_clean + "/Fail.png'>";
                }
                String infpopup =
                    "<body><table border=0>" +
                    "	<tr><td><b>"+
                    theType +
                    "		"+ nameHtml + "</b>" +
                    "	</td>"+
                    "	<td align='right'><h4>"+ _geo._Code + "</h4></td></tr>" +
                    stats +
                    "		<tr><td>"+ _daddy.GetTranslator().GetString("HTMLACacheBy") + ":&nbsp;" + MyTools.RemoveDiacritics(_geo._PlacedBy).Replace("'", " ") + "</td>" +
                    "		<td>"+ _daddy.GetTranslator().GetString("HTMLHidden") + ":&nbsp;" + MyTools.CleanDate(_geo._DateCreation) + "</td></tr>" +
                    "		<tr><td>"+ _daddy.GetTranslator().GetString("HTMLDifficulty") + ":&nbsp;<img src='" + imgpath_clean + "/Star/" + _geo._D + ".gif'></td>" +
                    "		<td>"+ _daddy.GetTranslator().GetString("HTMLTerrain") + ":&nbsp;<img src='" + imgpath_clean + "/Star/" + _geo._T + ".gif'></td></tr>" +
                    "		<tr><td>"+ _daddy.GetTranslator().GetString("HTMLSize") + ":&nbsp;<img src='" + imgpath_clean + "/Size/" + _geo._Container + ".gif'></td>";

                if ((_geo._Ocd != null) && (_geo._Ocd._dAltiMeters != Double.MaxValue))
                {
                    String salti = "";
                    if (_daddy._bUseKm)
                    {
                        salti = String.Format("{0:0.#}", _geo._Ocd._dAltiMeters) + " m";
                    }
                    else
                    {
                        salti = String.Format("{0:0.#}", _geo._Ocd._dAltiMeters * 3.2808399) + " ft";
                    }
                    infpopup += "<td>" + _daddy.GetTranslator().GetString("HTMLAltitude") + ":&nbsp;" + salti + "</td>";
                }
                else
                {
                    infpopup += "<td>&nbsp;</td>";
                }
                infpopup += "</tr></table></body>";

                // A VIRER !!!!!!!!!!
                //_daddy.Log(infpopup);


                Image   img = null;
                CssData css = CssData.Parse("body { font:8pt Tahoma } h3 { color: navy; font-weight:normal; }", true);
                img = HtmlRender.RenderToImage(infpopup, 330, 150, Color.White, css, null, null);

                System.Drawing.Size      st   = img.Size;
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(Marker.ToolTipPosition.X, Marker.ToolTipPosition.Y - st.Height / 2, st.Width + TextPadding.Width, st.Height + TextPadding.Height);
                rect.Offset(Offset.X, Offset.Y);

                g.DrawImage(img, new Point(rect.X, rect.Y));
            }
        }
Ejemplo n.º 58
0
        public void ProcessFrame(ref Image <Bgr, Byte> image, ref Image <Gray, Byte> gray, bool SetBitmap)
        {
            //Detect the faces  from the gray scale image and store the locations as rectangle
            //The first dimensional is the channel
            //The second dimension is the index of the rectangle in the specific channel
            //        The default
            //     parameters (scale_factor=1.1, min_neighbors=3, flags=0) are tuned for accurate
            //     yet slow object detection. For a faster operation on real video images the
            //     settings are: scale_factor=1.2, min_neighbors=2, flags=CV_HAAR_DO_CANNY_PRUNING,
            //     min_size=<minimum possible face size> (for example, ~1/4 to 1/16 of the image
            //     area in case of video conferencing).
            MCvAvgComp[][] facesDetected;
            if (AccurateAndSlow)
            {
                facesDetected = gray.DetectHaarCascade(face, 1.1, 3,
                                                       Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
            }
            else
            {
                //facesDetected = gray.DetectHaarCascade(face, 1.2, 2,
                //Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));

                facesDetected = gray.DetectHaarCascade(face, 1.2, 2,
                                                       Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(gray.Width / 8, gray.Height / 8));
            }

            //Clear perviuos list
            Faces.Clear();

            MCvAvgComp[][] eyesDetected = null;
            int            eyes         = 0;

            foreach (MCvAvgComp f in facesDetected[0])
            {
                //Set the region of interest on the faces
                gray.ROI = f.rect;

                //draw the face detected in the 0th (gray) channel with blue color
                if (SetBitmap)
                {
                    image.Draw(f.rect, new Bgr(System.Drawing.Color.Blue), 2);
                }

                if (FindEyes)
                {
                    eyesDetected = gray.DetectHaarCascade(eye, 1.1, 1, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
                    gray.ROI     = System.Drawing.Rectangle.Empty;

                    //if there is no eye in the specific region, the region shouldn't contains a face
                    //note that we might not be able to recoginize a person who ware glass in this case
                    if (eyesDetected[0].Length == 0)
                    {
                        continue;
                    }



                    foreach (MCvAvgComp ey in eyesDetected[0])
                    {
                        if (ey.neighbors > 100)
                        {
                            if (SetBitmap)
                            {
                                System.Drawing.Rectangle eyeRect = ey.rect;
                                eyeRect.Offset(f.rect.X, f.rect.Y);
                                image.Draw(eyeRect, new Bgr(System.Drawing.Color.Red), 2);
                            }
                        }
                    }
                }
                if (!(eyesDetected == null))
                {
                    eyes = eyesDetected[0].Length;
                }
                Faces.Add(new FaceController(f, eyes));
            }
        }
Ejemplo n.º 59
0
        /// <summary>
        /// This method paints the text and text shadow for the button.
        /// </summary>
        /// <param name="e">paint arguments use to paint the button</param>
        private void paint_Text(PaintEventArgs e)
        {
            if (e == null)
            {
                return;
            }
            if (e.Graphics == null)
            {
                return;
            }
            System.Drawing.Rectangle rect = GetTextDestinationRect();
            //
            // do offset if button is pushed
            //
            if ((btnState == BtnState.Pushed) && (OffsetPressedContent))
            {
                rect.Offset(1, 1);
            }
            //
            // caculate bounding rectagle for the text
            //
            System.Drawing.SizeF size = txt_Size(e.Graphics, this.Text, this.Font);
            //
            // calculate the starting location to paint the text
            //
            System.Drawing.Point pt = Calculate_LeftEdgeTopEdge(this.TextAlign, rect, (int)size.Width, (int)size.Height);
            //
            // If button state is inactive, paint the inactive text
            //
            if (btnState == BtnState.Inactive)
            {
                e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(System.Drawing.Color.White), pt.X + 1, pt.Y + 1);
                e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(System.Drawing.Color.FromArgb(50, 50, 50)), pt.X, pt.Y);
            }
            //
            // else, paint the text and text shadow
            //
            else
            {
                //
                // paint text shadow
                //
                if (TextDropShadow)
                {
                    System.Drawing.Brush TransparentBrush0 = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(50, System.Drawing.Color.Black));
                    System.Drawing.Brush TransparentBrush1 = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(20, System.Drawing.Color.Black));

                    e.Graphics.DrawString(this.Text, this.Font, TransparentBrush0, pt.X, pt.Y + 1);
                    e.Graphics.DrawString(this.Text, this.Font, TransparentBrush0, pt.X + 1, pt.Y);

                    e.Graphics.DrawString(this.Text, this.Font, TransparentBrush1, pt.X + 1, pt.Y + 1);
                    e.Graphics.DrawString(this.Text, this.Font, TransparentBrush1, pt.X, pt.Y + 2);
                    e.Graphics.DrawString(this.Text, this.Font, TransparentBrush1, pt.X + 2, pt.Y);

                    TransparentBrush0.Dispose();
                    TransparentBrush1.Dispose();
                }
                //
                // paint text
                //
                e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), pt.X, pt.Y);
            }
        }
Ejemplo n.º 60
0
        /// <summary>
        /// 已重载:绘制文档内容
        /// </summary>
        /// <param name="e">绘制事件参数</param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            //if (this.DesignMode)
            {
                base.OnPaint(e);
            }
            if (this.IsUpdating)
            {
                return;
            }

            System.Drawing.Rectangle clipRect = e.ClipRectangle;
            clipRect.Height += 1;
            System.Drawing.Point sp = this.AutoScrollPosition;
            //int ax = - this.AutoScrollPosition.X ;
            //int ay = - this.AutoScrollPosition.Y ;
            this.RefreshScaleTransform();
            if (this.PagesTransform == null || this.PagesTransform.Count == 0)
            {
                // 没有任何内容可以绘制
                return;
            }
            if (this.ViewMode == PageViewMode.Normal)
            {
                using (SolidBrush b = new SolidBrush(this.PageBackColor))
                {
                    e.Graphics.FillRectangle(b, e.ClipRectangle);
                }
                SimpleRectangleTransform item = this.PagesTransform[0];
                PrintPage myPage = (PrintPage)item.PageObject;

                Rectangle rect = item.SourceRect;
                rect.Width = rect.Width + 30;
                rect       = Rectangle.Intersect(
                    clipRect,
                    rect);

                if (rect.IsEmpty == false)
                {
                    // 保存状态
                    System.Drawing.Drawing2D.GraphicsState state2 = e.Graphics.Save();

                    //try
                    {
                        PaintEventArgs e2 = this.CreatePaintEventArgs(e, item);
                        if (e2 != null)
                        {
                            PageDocumentPaintEventArgs e3 = new PageDocumentPaintEventArgs(
                                e2.Graphics,
                                e2.ClipRectangle,
                                myPage.Document,
                                myPage,
                                item.ContentStyle);
                            e3.ContentBounds = item.DescRect;
                            e3.RenderMode    = ContentRenderMode.Paint;
                            e3.PageIndex     = myPage.PageIndex;
                            e3.NumberOfPages = this.Pages.Count;
                            //e3.EditMode = this.EditMode;
                            if (myPage.Document != null)
                            {
                                myPage.Document.DrawContent(e3);
                            }//if
                        }
                    }
                    //catch (Exception ext)
                    //{
                    //    System.Console.WriteLine(ext.ToString());
                    //}
                    // 恢复状态
                    e.Graphics.Restore(state2);
                }
                return;
            }
//
            MultiPageTransform trans = ( MultiPageTransform )this.Transform;

//			trans.ClearSourceOffset();
//			trans.OffsetSource( sp.X , sp.Y , true );

            System.Drawing.Graphics g = e.Graphics;
            //System.Drawing.Drawing2D.GraphicsState stateBack = e.Graphics.Save();
            foreach (PrintPage myPage in this.Pages)
            {
                System.Drawing.Rectangle ClientBounds = myPage.ClientBounds;
                ClientBounds.Offset(sp);
                ClientBounds.Width = ClientBounds.Width + 20;
                //if( clipRect.Top <= ClientBounds.Bottom  + 5
                //    && clipRect.Bottom >= ClientBounds.Top )
                if (clipRect.IntersectsWith(
                        new Rectangle(
                            ClientBounds.Left,
                            ClientBounds.Top,
                            ClientBounds.Width + 5,
                            ClientBounds.Height + 5)))
                {
                    //this.SetPageIndex( myPage.Index );

                    //e.Graphics.Restore(stateBack);
                    //e.Graphics.ResetClip();
                    DrawPageFrame(
                        myPage,
                        e.Graphics,
                        clipRect,
                        true);

                    for (int iCount = trans.Count - 1; iCount >= 0; iCount--)
                    {
                        SimpleRectangleTransform item = trans[iCount];
                        if (item.Visible && item.PageObject == myPage)
                        {
                            // 显示页眉页脚标记文本
                            if (item.ContentStyle == PageContentPartyStyle.Header)
                            {
                                if (this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.Header ||
                                    this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.HeaderFooter)
                                {
                                    // 绘制页眉标记
                                    //e.Graphics.Restore(stateBack);
                                    DrawHeaderFooterFlag(
                                        PrintingResources.Header,
                                        item.PartialAreaSourceBounds,
                                        e.Graphics);
                                }
                            }
                            else if (item.ContentStyle == PageContentPartyStyle.Footer)
                            {
                                if (this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.Footer ||
                                    this.HeaderFooterFlagVisible == HeaderFooterFlagVisible.HeaderFooter)
                                {
                                    // 绘制页脚标记
                                    //e.Graphics.Restore(stateBack);
                                    DrawHeaderFooterFlag(
                                        PrintingResources.Footer,
                                        item.PartialAreaSourceBounds,
                                        e.Graphics);
                                }
                            }
                            Rectangle rect = item.SourceRect;

                            rect = Rectangle.Intersect(
                                clipRect,
                                rect);

                            if (rect.IsEmpty == false)
                            {
                                System.Drawing.Drawing2D.GraphicsState state2 = e.Graphics.Save();

                                PaintEventArgs e2 = this.CreatePaintEventArgs(e, item);
                                if (e2 != null)
                                {
                                    PageDocumentPaintEventArgs e3 = new PageDocumentPaintEventArgs(
                                        e2.Graphics,
                                        e2.ClipRectangle,
                                        myPage.Document,
                                        myPage,
                                        item.ContentStyle);
                                    e3.ContentBounds = item.DescRect;
                                    e3.RenderMode    = ContentRenderMode.Paint;
                                    e3.PageIndex     = myPage.PageIndex;
                                    e3.NumberOfPages = this.Pages.Count;
                                    //e3.EditMode = this.EditMode;
                                    if (myPage.Document != null)
                                    {
                                        myPage.Document.DrawContent(e3);
                                    }//if
                                }

                                e.Graphics.Restore(state2);

                                if (item.Enable == false)
                                {
                                    // 若区域无效则用白色半透明进行覆盖,以作标记
                                    using (System.Drawing.SolidBrush maskBrush
                                               = new SolidBrush(Color.FromArgb(140, this.PageBackColor)))
                                    {
                                        e.Graphics.FillRectangle(
                                            maskBrush,
                                            rect.Left,
                                            rect.Top,
                                            rect.Width + 2,
                                            rect.Height + 2);
                                    }
                                }
                            }                            //if
                            // ClipRect.Height -= 1;
                        }
                    }    //foreach
                }        //if
            }            //foreach
            DrawHeadShadow();
            //base.OnPaint( e );
            //e.Graphics.Flush(System.Drawing.Drawing2D.FlushIntention.Sync);
            //System.Threading.Thread.Sleep(100);
        }