예제 #1
0
 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);
 }
예제 #2
0
        /// <summary>Update the rectangles for the control</summary>
        protected override void UpdateRectangles()
        {
            // First get the bounding box
            base.UpdateRectangles();

            // Create the button rect
            buttonRect       = boundingBox;
            buttonRect.Width = buttonRect.Height; // Make it square

            // Offset it
            buttonRect.Offset(-buttonRect.Width / 2, 0);
            buttonX = (int)((currentValue - minValue) * (float)boundingBox.Width / (maxValue - minValue));
            buttonRect.Offset(buttonX, 0);
        }
        public static VisibleMessagesIndexes GetVisibleMessages(DrawContext drawContext, IPresentationDataAccess presentationDataAccess, Rectangle viewRect)
        {
            VisibleMessagesIndexes rv;

            viewRect.Offset(0, drawContext.ScrollPos.Y);

            rv.begin             = viewRect.Y / drawContext.LineHeight;
            rv.fullyVisibleBegin = rv.begin;
            if ((viewRect.Y % drawContext.LineHeight) != 0)
            {
                ++rv.fullyVisibleBegin;
            }

            rv.end             = viewRect.Bottom / drawContext.LineHeight;
            rv.fullyVisibleEnd = rv.end;
            --rv.fullyVisibleEnd;
            if ((viewRect.Bottom % drawContext.LineHeight) != 0)
            {
                ++rv.end;
            }

            int availableLines = presentationDataAccess.ViewLinesCount;

            rv.begin           = Math.Min(availableLines, rv.begin);
            rv.end             = Math.Min(availableLines, rv.end);
            rv.fullyVisibleEnd = Math.Min(availableLines, rv.fullyVisibleEnd);

            return(rv);
        }
예제 #4
0
 //Handle mouse movement
 private void onMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (mouseDown && e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         if (stim1.Contains(e.Location))
         {
             offset.X = e.X - prevLoc.X;
             offset.Y = e.Y - prevLoc.Y;
             prevLoc  = e.Location;
             stim1.Offset(offset);
         }
         else if (stim2.Contains(e.Location))
         {
             offset.X = e.X - prevLoc.X;
             offset.Y = e.Y - prevLoc.Y;
             prevLoc  = e.Location;
             stim2.Offset(offset);
         }
         else if (stim3.Contains(e.Location))
         {
             offset.X = e.X - prevLoc.X;
             offset.Y = e.Y - prevLoc.Y;
             prevLoc  = e.Location;
             stim3.Offset(offset);
         }
         else if (stim4.Contains(e.Location))
         {
             offset.X = e.X - prevLoc.X;
             offset.Y = e.Y - prevLoc.Y;
             prevLoc  = e.Location;
             stim4.Offset(offset);
         }
     }
 }
예제 #5
0
        protected void DrawControlBorder(System.IntPtr hdc)
        {
            //
            // Investigated with .NET Reflector.
            //

            System.Drawing.Rectangle r = GetCanvasBounds();
            int cx = NativeMethods.GetSystemMetrics(NativeMethods.SM_CXEDGE);
            int cy = NativeMethods.GetSystemMetrics(NativeMethods.SM_CYEDGE);

            r.Offset(-cx, -cy);

            NativeMethods.RECT rect;
            rect.left   = r.Left;
            rect.top    = r.Top;
            rect.right  = r.Right;
            rect.bottom = r.Bottom;

            int edge        = (int)_borderStyle & 15;
            int borderFlags = (int)(System.Windows.Forms.Border3DSide.Left | System.Windows.Forms.Border3DSide.Right | System.Windows.Forms.Border3DSide.Top | System.Windows.Forms.Border3DSide.Bottom);

            borderFlags |= (int)(_borderStyle & ~(System.Windows.Forms.Border3DStyle.Sunken | System.Windows.Forms.Border3DStyle.Raised));

            if ((borderFlags & 0x2000) == 0x2000)
            {
                System.Drawing.Size borderSize = System.Windows.Forms.SystemInformation.Border3DSize;
                rect.left   -= borderSize.Width;
                rect.right  += borderSize.Width;
                rect.top    -= borderSize.Height;
                rect.bottom += borderSize.Height;
                borderFlags &= -8193;
            }

            NativeMethods.DrawEdge(hdc, ref rect, edge, borderFlags);
        }
예제 #6
0
        public Region CompensateRegionPosition(Region region, double pixelRatio)
        {
            if (pixelRatio == 1.0)
            {
                return(region);
            }

            EyesWebDriver eyesWebDriver = eyes.GetDriver();
            FrameChain    frameChain    = eyesWebDriver.GetFrameChain();

            if (frameChain.Count > 0)
            {
                return(region);
            }

            System.Drawing.Rectangle rect = region.ToRectangle();
            rect.Offset(0, -(int)Math.Ceiling(pixelRatio / 2));

            if (rect.Width <= 0 || rect.Height <= 0)
            {
                return(Region.Empty);
            }

            Region compensatedRegion = new Region(rect);

            logger.Verbose($"compensating for firefox: {region} ==> {compensatedRegion}");

            return(compensatedRegion);
        }
예제 #7
0
        public static void Draw3DButton(System.Drawing.Graphics g, System.Drawing.Rectangle rect, bool isPressed)
        {
            // background
            WFRect bgRect = rect;

            //bgRect.Inflate(-1, -1);
            bgRect.Offset(1, 1);
            g.FillRectangle(isPressed ? RGBrushes.Black : RGBrushes.White, bgRect);

            // outter frame
            g.DrawLine(System.Drawing.Pens.Black, rect.X + 1, rect.Y, rect.Right - 1, rect.Y);
            g.DrawLine(System.Drawing.Pens.Black, rect.X + 1, rect.Bottom, rect.Right - 1, rect.Bottom);
            g.DrawLine(System.Drawing.Pens.Black, rect.X, rect.Y + 1, rect.X, rect.Bottom - 1);
            g.DrawLine(System.Drawing.Pens.Black, rect.Right, rect.Y + 1, rect.Right, rect.Bottom - 1);

            // content
            WFRect bodyRect = rect;

            bodyRect.Inflate(-1, -1);
            bodyRect.Offset(1, 1);
            g.FillRectangle(System.Drawing.Brushes.LightGray, bodyRect);

            // shadow
            g.DrawLines(isPressed ? RGPens.White : System.Drawing.Pens.DimGray, new System.Drawing.Point[] {
                new System.Drawing.Point(rect.Left + 1, rect.Bottom - 1),
                new System.Drawing.Point(rect.Right - 1, rect.Bottom - 1),
                new System.Drawing.Point(rect.Right - 1, rect.Top + 1),
            });
        }
예제 #8
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            if (DesignMode)
            {
                base.OnPaint(pe); return;
            }

            var checkboxLocation = new System.Drawing.Rectangle(0, 0, 10, 10);

            checkboxLocation.Offset(pe.ClipRectangle.Location);
            var innerLocation = new System.Drawing.Rectangle(3, 3, 5, 5);

            innerLocation.Offset(pe.ClipRectangle.Location);
            var textLocation = new System.Drawing.Point(pe.ClipRectangle.Location.X, pe.ClipRectangle.Location.Y);

            textLocation.Offset(15, 0);

            if (this.Checked)
            {
                pe.Graphics.FillRectangle(InkCheckedCheckBox.AsBrush(), checkboxLocation);
                pe.Graphics.FillRectangle(InkCheckedCheckBoxInner.AsBrush(), innerLocation);
                pe.Graphics.DrawRectangle(InkCheckedCheckBoxBorder.AsPen(), checkboxLocation);
            }
            else
            {
                pe.Graphics.FillRectangle(InkEmptyCheckBox.AsBrush(), checkboxLocation);
                pe.Graphics.DrawRectangle(InkEmptyCheckBoxBorder.AsPen(), checkboxLocation);
            }

            pe.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
            pe.Graphics.DrawString(this.Text, this.Font, InkTextColor.AsBrush(), textLocation);
        }
예제 #9
0
        private void DrawViewportBackground(Aurigma.GraphicsMill.Bitmap canvas, System.Drawing.Rectangle viewport, System.Drawing.Rectangle renderingRegion)
        {
            using (Aurigma.GraphicsMill.Drawing.Graphics g = canvas.GetGraphics())
            {
                System.Drawing.Rectangle screenRect = renderingRegion;
                screenRect.X -= viewport.X;
                screenRect.Y -= viewport.Y;

                if (_workspaceBackgroundStyle == Aurigma.GraphicsMill.WinControls.WorkspaceBackgroundStyle.Grid)
                {
                    int gridPatternSize = 2 * bgGridCellSize;
                    int patternOffsetX  = renderingRegion.X % gridPatternSize,
                        patternOffsetY  = renderingRegion.Y % gridPatternSize;

                    CreateBackgroundGridTemplate(renderingRegion.Width + gridPatternSize);

                    System.Drawing.Rectangle srcRect = new System.Drawing.Rectangle(0, 0, _bgGridTemplate.Width, _bgGridTemplate.Height),
                                             dstRect = new System.Drawing.Rectangle(renderingRegion.Location, srcRect.Size);
                    dstRect.Offset(-viewport.X, -viewport.Y);
                    dstRect.Offset(-patternOffsetX, -patternOffsetY);

                    g.SetClip(new System.Drawing.Rectangle(renderingRegion.X - viewport.X, renderingRegion.Y - viewport.Y, renderingRegion.Width, renderingRegion.Height));
                    try
                    {
                        int templateRepeats = (int)System.Math.Ceiling((float)(renderingRegion.Height + patternOffsetY) / _bgGridTemplate.Height);
                        for (int j = 0; j < templateRepeats; j++)
                        {
                            g.DrawImage(_bgGridTemplate, dstRect, /*srcRect,*/ Aurigma.GraphicsMill.Transforms.CombineMode.Copy, 1.0f, Aurigma.GraphicsMill.Transforms.ResizeInterpolationMode.NearestNeighbour);
                            dstRect.Offset(0, _bgGridTemplate.Height);
                        }
                    }
                    finally
                    {
                        g.ResetClip();
                    }
                }
                else if (_workspaceBackgroundStyle == Aurigma.GraphicsMill.WinControls.WorkspaceBackgroundStyle.Solid)
                {
                    g.FillRectangle(new Aurigma.GraphicsMill.Drawing.SolidBrush(_workspaceBackColor1), screenRect);
                }
                else
                {
                    g.FillRectangle(new Aurigma.GraphicsMill.Drawing.SolidBrush(_backColor), screenRect);
                }
            }
        }
예제 #10
0
        /// <summary>Render the button</summary>
        public override void Render(Device device, float elapsedTime)
        {
            int offsetX = 0;
            int offsetY = 0;

            ControlState state = ControlState.Normal;

            if (IsVisible == false)
            {
                state = ControlState.Hidden;
            }
            else if (IsEnabled == false)
            {
                state = ControlState.Disabled;
            }
            else if (isPressed)
            {
                state   = ControlState.Pressed;
                offsetX = 1;
                offsetY = 2;
            }
            else if (isMouseOver)
            {
                state   = ControlState.MouseOver;
                offsetX = -1;
                offsetY = -2;
            }
            else if (hasFocus)
            {
                state = ControlState.Focus;
            }

            // Background fill layer
            Element e         = elementList[Button.ButtonLayer] as Element;
            float   blendRate = (state == ControlState.Pressed) ? 0.0f : 0.8f;

            System.Drawing.Rectangle buttonRect = boundingBox;
            buttonRect.Offset(offsetX, offsetY);

            // Blend current color
            e.TextureColor.Blend(state, elapsedTime, blendRate);
            e.FontColor.Blend(state, elapsedTime, blendRate);

            // Draw sprite/text of button
            parentDialog.DrawSprite(e, buttonRect);
            parentDialog.DrawText(textData, e, buttonRect);

            // Main button
            e = elementList[Button.FillLayer] as Element;

            // Blend current color
            e.TextureColor.Blend(state, elapsedTime, blendRate);
            e.FontColor.Blend(state, elapsedTime, blendRate);

            parentDialog.DrawSprite(e, buttonRect);
            parentDialog.DrawText(textData, e, buttonRect);
        }
예제 #11
0
        private void CreateBackgroundGridTemplate(int width)
        {
            if (width < 1)
            {
                throw new System.ArgumentOutOfRangeException("width", StringResources.GetString("ExStrValueShouldBeAboveZero"));
            }
            if (_bgGridTemplate != null && _bgGridTemplate.Width >= width)
            {
                return;
            }

            if (_bgGridTemplate != null)
            {
                _bgGridTemplate.Dispose();
            }

            _bgGridTemplate = new Aurigma.GraphicsMill.Bitmap(width, 2 * bgGridCellSize, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb);

            using (Aurigma.GraphicsMill.Drawing.Graphics g = _bgGridTemplate.GetGraphics())
            {
                Aurigma.GraphicsMill.Drawing.SolidBrush brush0 = new Aurigma.GraphicsMill.Drawing.SolidBrush(_workspaceBackColor1),
                                                        brush1 = new Aurigma.GraphicsMill.Drawing.SolidBrush(_workspaceBackColor2);

                System.Drawing.Rectangle cellRect = new System.Drawing.Rectangle(0, 0, bgGridCellSize, bgGridCellSize);

                int n = (int)System.Math.Ceiling((float)width / (2.0f * bgGridCellSize));
                for (int i = 0; i < n; i++)
                {
                    g.FillRectangle(brush0, cellRect);
                    cellRect.Offset(bgGridCellSize, 0);
                    g.FillRectangle(brush1, cellRect);
                    cellRect.Offset(bgGridCellSize, 0);
                }

                cellRect.Location = new System.Drawing.Point(0, bgGridCellSize);
                for (int i = 0; i < n; i++)
                {
                    g.FillRectangle(brush1, cellRect);
                    cellRect.Offset(bgGridCellSize, 0);
                    g.FillRectangle(brush0, cellRect);
                    cellRect.Offset(bgGridCellSize, 0);
                }
            }
        }
예제 #12
0
 /// <summary>
 /// 移动矩形
 /// </summary>
 /// <param name="dx">横向移动量</param>
 /// <param name="dy">纵向移动量</param>
 /// <param name="DragStyle">移动方式</param>
 /// <param name="SourceRect">原始矩形</param>
 /// <returns>移动后的矩形</returns>
 public static System.Drawing.Rectangle CalcuteDragRectangle(
     int dx,
     int dy,
     DragPointStyle DragStyle,
     System.Drawing.Rectangle SourceRect)
 {
     // 中间
     if (DragStyle == DragPointStyle.Move)
     {
         SourceRect.Offset(dx, dy);
     }
     // 左边
     if (DragStyle == DragPointStyle.LeftTop ||
         DragStyle == DragPointStyle.LeftCenter ||
         DragStyle == DragPointStyle.LeftBottom)
     {
         SourceRect.Offset(dx, 0);
         SourceRect.Width = SourceRect.Width - dx;
     }
     // 顶边
     if (DragStyle == DragPointStyle.LeftTop ||
         DragStyle == DragPointStyle.TopCenter ||
         DragStyle == DragPointStyle.TopRight)
     {
         SourceRect.Offset(0, dy);
         SourceRect.Height = SourceRect.Height - dy;
     }
     // 右边
     if (DragStyle == DragPointStyle.TopRight ||
         DragStyle == DragPointStyle.RightCenter ||
         DragStyle == DragPointStyle.RightBottom)
     {
         SourceRect.Width = SourceRect.Width + dx;
     }
     // 底边
     if (DragStyle == DragPointStyle.RightBottom ||
         DragStyle == DragPointStyle.BottomCenter ||
         DragStyle == DragPointStyle.LeftBottom)
     {
         SourceRect.Height = SourceRect.Height + dy;
     }
     return(SourceRect);
 }
예제 #13
0
        /*public string ByteArrayToString(byte[] ba)
         * {
         * StringBuilder hex = new StringBuilder(ba.Length * 2);
         * foreach (byte b in ba)
         * hex.AppendFormat("{0:x2}", b);
         * return hex.ToString();
         * }*/

        private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
        {
            TabPage page = tabControl1.TabPages[e.Index];

            e.Graphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(25, 32, 32, 32)), e.Bounds);
            System.Drawing.Rectangle paddedBounds = e.Bounds;
            int yOffset = (e.State == DrawItemState.Selected) ? -2 : 1;

            paddedBounds.Offset(1, yOffset);
            TextRenderer.DrawText(e.Graphics, page.Text, Font, paddedBounds, System.Drawing.Color.FromArgb(64, 16, 16, 16));
        }
예제 #14
0
 public void OffsetSource(int dx, int dy, bool Remark)
 {
     if (Remark)
     {
         mySourceOffsetBack.Offset(dx, dy);
     }
     foreach (SimpleRectangleTransform item in this)
     {
         System.Drawing.Rectangle rect = item.SourceRect;
         rect.Offset(dx, dy);
         item.SourceRect = rect;
     }
 }
예제 #15
0
 public void ClearSourceOffset()
 {
     if (mySourceOffsetBack.IsEmpty == false)
     {
         foreach (SimpleRectangleTransform item in this)
         {
             System.Drawing.Rectangle rect = item.SourceRect;
             rect.Offset(-mySourceOffsetBack.X, -mySourceOffsetBack.Y);
             item.SourceRect = rect;
         }
     }
     mySourceOffsetBack = System.Drawing.Point.Empty;
 }
예제 #16
0
        /// <summary>
        /// Update the rectangles
        /// </summary>
        protected override void UpdateRectangles()
        {
            // Update base first
            base.UpdateRectangles();

            // Update the two rects
            buttonRect = boundingBox;
            buttonRect = new System.Drawing.Rectangle(boundingBox.Location,
                                                      new System.Drawing.Size(boundingBox.Height, boundingBox.Height));

            textRect = boundingBox;
            textRect.Offset((int)(1.25f * buttonRect.Width), 0);
        }
        public Region CompensateRegionPosition(Region region, double pixelRatio)
        {
            if (pixelRatio == 1.0)
            {
                return(region);
            }

            if (region.Width <= 0 || region.Height <= 0)
            {
                return(Region.Empty);
            }

            System.Drawing.Rectangle rect = region.ToRectangle();
            rect.Offset(0, (int)Math.Ceiling(pixelRatio));
            return(new Region(rect));
        }
예제 #18
0
        public System.Drawing.Rectangle DrawCached(Aurigma.GraphicsMill.Drawing.Graphics g, float zoom, System.Drawing.Rectangle viewport, System.Drawing.Rectangle renderingRegion)
        {
            if (!HasActualData(zoom, renderingRegion))
            {
                return(System.Drawing.Rectangle.Empty);
            }

            System.Drawing.Rectangle intersection = System.Drawing.Rectangle.Intersect(renderingRegion, _viewport),
                                     dstRect      = intersection,
                                     srcRect      = intersection;

            srcRect.Offset(-_viewport.X, -_viewport.Y);
            dstRect.Offset(-viewport.X, -viewport.Y);

            g.DrawImage(_image, dstRect, srcRect, Aurigma.GraphicsMill.Transforms.CombineMode.Copy, 1.0f, Aurigma.GraphicsMill.Transforms.ResizeInterpolationMode.Low);
            return(intersection);
        }
예제 #19
0
        /// <summary>
        /// 已重载:打印一页内容
        /// </summary>
        /// <param name="e">事件参数</param>
        protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e)
        {
            base.OnPrintPage(e);
            if (e.Cancel)
            {
                return;
            }
            if (myPageEnumerator != null)
            {
                PrintPage myPage = (PrintPage)myPageEnumerator.Current;

                //myPage.Document.PageIndex = myPage.GlobalIndex;
                //myDocument.PageIndex = intCurrentPageIndex ;
                System.Drawing.Rectangle ClipRect = new System.Drawing.Rectangle(
                    myPage.Left,
                    myPage.Top,
                    myPage.Width,
                    myPage.Height);
                bool bolJumpPrint = false;
                if (this.JumpPrint.Enabled &&
                    this.JumpPrint.Page == myPage)
                {
                    //if( this.JumpPrint.Position > myPage.Top && this.JumpPrint.Position < myPage.Bottom )
                    {
                        int dy = this.JumpPrint.Position;// -myPage.Top;
                        ClipRect.Offset(0, dy);
                        ClipRect.Height = ClipRect.Height - dy;
                        bolJumpPrint    = true;
                    }
                }
                if (bolJumpPrint)
                {
                    OnPaintPage(myPage, e.Graphics, ClipRect, false, false, e);
                }
                else
                {
                    OnPaintPage(myPage, e.Graphics, ClipRect, true, true, e);
                }

                e.HasMorePages = myPageEnumerator.MoveNext();
                intPrintedPageCount++;
            }
        }
    public static Bitmap TakeScreenshot(this OpenQA.Selenium.IWebElement element)
    {
        RemoteWebDriver driver = (RemoteWebDriver)((RemoteWebElement)element).WrappedDriver;

        if (((IHasCapabilities)driver).Capabilities.HasCapability("takesElementScreenshot"))
        {
            byte[] bytes = ((RemoteWebElement)element).GetScreenshot().AsByteArray;
            return((Bitmap)Bitmap.FromStream(new MemoryStream(bytes, 0, bytes.Length, false, true), false, false));
        }
        else
        {
            var dict = (Dictionary <String, Object>)driver.ExecuteScript(@"
                    arguments[0].scrollIntoView(true);
                    var r = arguments[0].getBoundingClientRect(), scrollX = 0, scrollY = 0;
                    for(var e = arguments[0]; e; e=e.parentNode) {
                      scrollX += e.scrollLeft || 0;
                      scrollY += e.scrollTop || 0;
                    }
                    return {left: r.left|0, top: r.top|0, width: r.width|0, height: r.height|0
                           , scrollX: scrollX, scrollY: scrollY, innerHeight: window.innerHeight}; "
                                                                         , element);
            var rect = new System.Drawing.Rectangle(
                Convert.ToInt32(dict["left"]),
                Convert.ToInt32(dict["top"]),
                Convert.ToInt32(dict["width"]),
                Convert.ToInt32(dict["height"]));
            byte[] bytes = driver.GetScreenshot().AsByteArray;
            using (Bitmap bitmap = (Bitmap)Bitmap.FromStream(new MemoryStream(bytes, 0, bytes.Length, false, true), false, false)) {
                if (bitmap.Height > Convert.ToInt32(dict["innerHeight"]))
                {
                    rect.Offset(Convert.ToInt32(dict["scrollX"]), Convert.ToInt32(dict["scrollY"]));
                }
                rect.Intersect(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height));
                if (rect.Height == 0 || rect.Width == 0)
                {
                    throw new WebDriverException("WebElement is outside of the screenshot.");
                }
                return(bitmap.Clone(rect, bitmap.PixelFormat));
            }
        }
    }
예제 #21
0
        /// <summary>Update the rectangles for the combo box control</summary>
        protected override void UpdateRectangles()
        {
            // Get bounding box
            base.UpdateRectangles();

            // Update the bounding box for the items
            buttonRect = new System.Drawing.Rectangle(boundingBox.Right - boundingBox.Height, boundingBox.Top,
                                                      boundingBox.Height, boundingBox.Height);

            textRect      = boundingBox;
            textRect.Size = new System.Drawing.Size(textRect.Width - buttonRect.Width, textRect.Height);

            dropDownRect = textRect;
            dropDownRect.Offset(0, (int)(0.9f * textRect.Height));
            dropDownRect.Size = new System.Drawing.Size(dropDownRect.Width - scrollWidth, dropDownRect.Height + dropHeight);

            // Scale it down slightly
            System.Drawing.Point loc  = dropDownRect.Location;
            System.Drawing.Size  size = dropDownRect.Size;

            loc.X       += (int)(0.1f * dropDownRect.Width);
            loc.Y       += (int)(0.1f * dropDownRect.Height);
            size.Width  -= (2 * (int)(0.1f * dropDownRect.Width));
            size.Height -= (2 * (int)(0.1f * dropDownRect.Height));

            dropDownTextRect = new System.Drawing.Rectangle(loc, size);

            // Update the scroll bars rects too
            scrollbarControl.SetLocation(dropDownRect.Right, dropDownRect.Top + 2);
            scrollbarControl.SetSize(scrollWidth, dropDownRect.Height - 2);
            FontNode fNode = DialogResourceManager.GetGlobalInstance().GetFontNode((int)(elementList[2] as Element).FontIndex);

            if ((fNode != null) && (fNode.Height > 0))
            {
                scrollbarControl.PageSize = (int)(dropDownTextRect.Height / fNode.Height);

                // The selected item may have been scrolled off the page.
                // Ensure that it is in page again.
                scrollbarControl.ShowItem(selectedIndex);
            }
        }
예제 #22
0
        public PrinterBounds(PrintPageEventArgs e)
        {
            int iHardMarginLeft;
            int iHardMarginTop;

            IntPtr hDC = e.Graphics.GetHdc();

            iHardMarginLeft = GetDeviceCaps(hDC, PHYSICALOFFSETX);
            iHardMarginTop  = GetDeviceCaps(hDC, PHYSICALOFFSETY);

            e.Graphics.ReleaseHdc(hDC);

            HardMarginLeft = new Length(iHardMarginLeft, new CoordinateSystem.Units(System.Drawing.GraphicsUnit.Pixel));
            HardMarginTop  = new Length(iHardMarginTop, new CoordinateSystem.Units(System.Drawing.GraphicsUnit.Pixel));
            //float test = HardMarginLeft.InInch();
            Bounds = e.MarginBounds;
            Bounds.Offset(-(int)(iHardMarginLeft * 100.0 / e.Graphics.DpiX), -(int)(iHardMarginTop * 100.0 / e.Graphics.DpiY));
            System.Diagnostics.Debug.WriteLine("MarginBounds X: " + Bounds.X + " Y: " + Bounds.Y + " W: " + Bounds.Width + " H: " + Bounds.Height);
            HardMarginLeft.DPI = e.Graphics.DpiX;
            HardMarginTop.DPI  = e.Graphics.DpiY;
        }
예제 #23
0
        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),
                };
            }));
        }
예제 #24
0
        /// <summary>
        /// A part of the cached image lying inside the specified rectangle is draw on the given bitmap.
        /// No drawing is performed unless the cache is actual for the specified zoom.
        /// </summary>
        /// <returns>Return part of the rect that had been drawn from the cache (in viewportOrigin coordinates).</returns>
        public System.Drawing.Rectangle DrawCached(Aurigma.GraphicsMill.Bitmap canvas, float zoom, System.Drawing.Rectangle viewport, System.Drawing.Rectangle renderingRegion)
        {
            if (!HasActualData(zoom, renderingRegion))
            {
                return(System.Drawing.Rectangle.Empty);
            }

            System.Drawing.Rectangle intersection = System.Drawing.Rectangle.Intersect(renderingRegion, _viewport),
                                     dstRect      = intersection,
                                     srcRect      = intersection;

            srcRect.Offset(-_viewport.X, -_viewport.Y);
            dstRect.Offset(-viewport.X, -viewport.Y);

            using (var ct = new Aurigma.GraphicsMill.Transforms.Crop(srcRect))
                using (var cropResult = ct.Apply(_image))
                {
                    canvas.Draw(cropResult, dstRect.Left, dstRect.Top, Aurigma.GraphicsMill.Transforms.CombineMode.Copy);
                }

            return(intersection);
        }
예제 #25
0
        private void audioTab_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            System.Drawing.Point p = e.Location;
            for (int i = 0; i < audioTab.TabCount; i++)
            {
                System.Drawing.Rectangle rect = audioTab.GetTabRect(i);
                rect.Offset(2, 2);
                rect.Width  -= 4;
                rect.Height -= 4;
                if (rect.Contains(p))
                {
                    iSelectedAudioTabPage = i;
                    audioMenu.Show(audioTab, e.Location);
                    break;
                }
            }
        }
예제 #26
0
        /// <summary>
        /// Helper function to render icon description.  Broken out so that child classes can override this behavior.
        /// </summary>
        /// <param name="drawArgs"></param>
        protected override void RenderDescription(DrawArgs drawArgs, Sprite sprite, Vector3 projectedPoint, int color)
        {
            string description = this.GeneralInfo() + this.DetailedInfo() + this.DescriptionInfo();

            if (description != null)
            {
                // Render description field
                DrawTextFormat format = DrawTextFormat.NoClip | DrawTextFormat.WordBreak | DrawTextFormat.Bottom;
                int            left   = 10;
                if (World.Settings.ShowLayerManager)
                {
                    left += World.Settings.LayerManagerWidth;
                }
                Rectangle rect = Rectangle.FromLTRB(left, 10, drawArgs.screenWidth - 10, drawArgs.screenHeight - 10);

                // Draw description
                rect.Offset(1, -1);
                drawArgs.defaultDrawingFont.DrawText(
                    sprite, description,
                    rect,
                    format, descriptionColor);
            }
        }
예제 #27
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;
            string      text;

            if (drv == null)
            {
                text = string.Empty;
            }
            else
            {
                text = drv[this.MappingName].ToString();
            }

            if (htmlFormat)
            {
                string[] transformSections = r.Split(text);
                text = string.Join(" ", transformSections).Replace("\n", " ").Trim();
            }

            g.FillRectangle(backBrush, bounds);
            bounds.Offset(0, 2);
            g.DrawString(text, this.DataGridTableStyle.DataGrid.Font, foreBrush, bounds, System.Drawing.StringFormat.GenericDefault);
        }
예제 #28
0
        protected override void OnRender(RenderGraphics g)
        {
            var c = g.CreateCommandList();

            c.Transform.GetOrigin(out var ox, out var oy);

            // Background shadow.
            if (IsExpanded)
            {
                var fullscreenRect = new Rectangle(0, 0, ParentFormSize.Width, ParentFormSize.Height);
                fullscreenRect.Offset(-(int)ox, -(int)oy);
                c.FillRectangle(fullscreenRect, g.GetSolidBrush(Color.Black, 1.0f, popupRatio * 0.6f));
            }

            // Clear BG.
            var navBgRect = Rectangle.Empty;

            for (int i = 0; i < (int)ButtonType.Count; i++)
            {
                var btn = buttons[i];
                if (btn.Visible && btn.IsNavButton)
                {
                    navBgRect = navBgRect.IsEmpty ? btn.Rect : Rectangle.Union(navBgRect, btn.Rect);
                }
            }

            var bgRect = new Rectangle(0, 0, Width, Height);

            var navBgBrush = IsLandscape ?
                             g.GetHorizontalGradientBrush(Theme.DarkGreyLineColor1, buttonSize, 0.8f) :
                             g.GetVerticalGradientBrush(Theme.DarkGreyLineColor1, buttonSize, 0.8f);
            var bgBrush = IsLandscape ?
                          g.GetHorizontalGradientBrush(Theme.DarkGreyFillColor1, buttonSize, 0.8f) :
                          g.GetVerticalGradientBrush(Theme.DarkGreyFillColor1, buttonSize, 0.8f);

            c.FillRectangle(bgRect, bgBrush);
            c.FillRectangle(navBgRect, navBgBrush);

            // Buttons
            for (int i = 0; i < (int)ButtonType.Count; i++)
            {
                var btn = buttons[i];

                if (btn.Visible)
                {
                    var image = btn.GetRenderInfo(out var text, out var tint);
                    c.DrawBitmapAtlas(bmpButtonAtlas, (int)image, btn.IconX, btn.IconY, 1.0f, iconScaleFloat, tint);

                    if (!string.IsNullOrEmpty(text))
                    {
                        c.DrawText(text, buttonFont, btn.TextX, btn.TextY, ThemeResources.LightGreyFillBrush1, RenderTextFlags.Center | RenderTextFlags.Ellipsis, buttonSize, 0);
                    }
                }
            }

            // Dividing line.
            if (IsLandscape)
            {
                c.DrawLine(0, 0, 0, Height, ThemeResources.BlackBrush);
            }
            else
            {
                c.DrawLine(0, 0, Width, 0, ThemeResources.BlackBrush);
            }

            g.DrawCommandList(c);

            // List items.
            if (popupButtonIdx >= 0)
            {
                c = g.CreateCommandList();

                var rect = GetExpandedListRect();
                c.PushTranslation(rect.Left, rect.Top - scrollY);

                for (int i = 0; i < listItems.Length; i++)
                {
                    var item    = listItems[i];
                    var brush   = g.GetVerticalGradientBrush(item.Color, listItemSize, 0.8f);
                    var opacity = item.GetImageOpacity != null?item.GetImageOpacity(item) : 1.0f;

                    c.FillAndDrawRectangle(item.Rect, brush, ThemeResources.BlackBrush);
                    c.DrawBitmapAtlas(bmpButtonAtlas, item.ImageIndex, item.IconX, item.IconY, opacity, iconScaleFloat, Color.Black);

                    if (item.ExtraImageIndex >= 0)
                    {
                        var extraOpacity = item.GetExtraImageOpacity != null?item.GetExtraImageOpacity(item) : 1.0f;

                        c.DrawBitmapAtlas(bmpButtonAtlas, item.ExtraImageIndex, item.ExtraIconX, item.ExtraIconY, extraOpacity, iconScaleFloat, Color.Black);
                    }

                    c.DrawText(item.Text, i == popupSelectedIdx ? ThemeResources.FontMediumBold : ThemeResources.FontMedium, item.TextX, item.TextY, ThemeResources.BlackBrush, RenderTextFlags.Middle, 0, listItemSize);
                }

                c.PopTransform();

                var scrollBarRect = GetScrollBarRect();

                if ((Math.Abs(flingVelY) > 0.0f || captureOperation == CaptureOperation.MobilePan) && !scrollBarRect.IsEmpty)
                {
                    c.PushTranslation(rect.Left, rect.Top);
                    c.FillRectangle(GetScrollBarRect(), scrollBarBrush);
                    c.PopTransform();
                }

                if (IsLandscape)
                {
                    rect.Width = -rect.X;
                }
                else
                {
                    rect.Height = -rect.Y;
                }

                rect.Offset((int)Math.Round(ox), (int)Math.Round(oy));
                g.DrawCommandList(c, rect);
            }
        }
예제 #29
0
        public override void Render(DrawArgs drawArgs)
        {
            try
            {
                lock (this)
                {
                    //override colors for visibility
                    switch (World.Settings.WFSNameColors)
                    {
                    case WFSNameColors.Black:
                        m_renderColor = System.Drawing.Color.Black.ToArgb();
                        break;

                    case WFSNameColors.White:
                        m_renderColor = System.Drawing.Color.White.ToArgb();
                        break;

                    case WFSNameColors.Gray:
                        m_renderColor = System.Drawing.Color.DarkGray.ToArgb();
                        break;

                    case WFSNameColors.Default:
                        m_renderColor = m_defaultColor;
                        break;
                    }

                    if (World.Settings.WFSNameSizeMultiplier != m_fontScaling)
                    {
                        m_fontScaling = World.Settings.WFSNameSizeMultiplier;
                        // scale font size based on settings
                        FontDescription scaledDescription = m_fontDescription;
                        scaledDescription.Height = (int)(m_fontDescription.Height * m_fontScaling);
                        m_drawingFont            = drawArgs.CreateFont(scaledDescription);
                    }

                    Vector3 cameraPosition = drawArgs.WorldCamera.Position;
                    if (m_placeNames == null)
                    {
                        return;
                    }

                    // Black outline for light text, white outline for dark text
                    int outlineColor = unchecked ((int)0x80ffffff);
                    int brightness   = (m_renderColor & 0xff) +
                                       ((m_renderColor >> 8) & 0xff) +
                                       ((m_renderColor >> 16) & 0xff);
                    if (brightness > 255 * 3 / 2)
                    {
                        outlineColor = unchecked ((int)0x80000000);
                    }

                    if (m_sprite != null)
                    {
                        m_sprite.Begin(SpriteFlags.AlphaBlend);
                    }
                    int     count           = 0;
                    Vector3 referenceCenter = new Vector3(
                        (float)drawArgs.WorldCamera.ReferenceCenter.X,
                        (float)drawArgs.WorldCamera.ReferenceCenter.Y,
                        (float)drawArgs.WorldCamera.ReferenceCenter.Z);

                    for (int index = 0; index < m_placeNames.Length; index++)
                    {
                        Vector3 v = m_placeNames[index].cartesianPoint;
                        float   distanceSquared = Vector3.LengthSq(v - cameraPosition);
                        if (distanceSquared > m_maximumDistanceSq)
                        {
                            continue;
                        }

                        if (distanceSquared < m_minimumDistanceSq)
                        {
                            continue;
                        }

                        if (!drawArgs.WorldCamera.ViewFrustum.ContainsPoint(v))
                        {
                            continue;
                        }

                        Vector3 pv = drawArgs.WorldCamera.Project(v - referenceCenter);

                        // Render text only
                        string label = m_placeNames[index].Name;


                        /*
                         * if(m_sprite != null && 1==0)
                         * {
                         *      m_sprite.Draw(m_iconTexture,
                         *              m_spriteSize,
                         *              new Vector3(m_spriteSize.Width/2,m_spriteSize.Height/2,0),
                         *              new Vector3(pv.X, pv.Y, 0),
                         *              System.Drawing.Color.White);
                         *      pv.X += m_spriteSize.Width/2 + 4;
                         * }
                         */

                        System.Drawing.Rectangle rect = m_drawingFont.MeasureString(null, label, m_textFormat, m_renderColor);

                        pv.Y -= rect.Height / 2;
                        if (m_sprite == null)
                        {
                            // Center horizontally
                            pv.X -= rect.Width / 2;
                        }

                        rect.Inflate(3, 1);
                        int x = (int)Math.Round(pv.X);
                        int y = (int)Math.Round(pv.Y);

                        rect.Offset(x, y);

                        if (World.Settings.WFSOutlineText)
                        {
                            m_drawingFont.DrawText(null, label, x - 1, y - 1, outlineColor);
                            m_drawingFont.DrawText(null, label, x - 1, y + 1, outlineColor);
                            m_drawingFont.DrawText(null, label, x + 1, y - 1, outlineColor);
                            m_drawingFont.DrawText(null, label, x + 1, y + 1, outlineColor);
                        }

                        m_drawingFont.DrawText(null, label, x, y, m_renderColor);

                        count++;
                        if (count > 30)
                        {
                            break;
                        }
                    }

                    if (m_sprite != null)
                    {
                        m_sprite.End();
                    }
                }
            }
            catch (Exception caught)
            {
                Log.Write(caught);
            }
        }
예제 #30
0
        /// <summary>
        /// Update the rectangles
        /// </summary>
        protected override void UpdateRectangles()
        {
            // Update base first
            base.UpdateRectangles();

            // Update the two rects
            buttonRect = boundingBox;
            buttonRect = new System.Drawing.Rectangle(boundingBox.Location,
                new System.Drawing.Size(boundingBox.Height, boundingBox.Height));

            textRect = boundingBox;
            textRect.Offset((int) (1.25f * buttonRect.Width), 0);
        }
예제 #31
0
        /// <summary>Update the rectangles for the control</summary>
        protected override void UpdateRectangles()
        {
            // First get the bounding box
            base.UpdateRectangles ();

            // Create the button rect
            buttonRect = boundingBox;
            buttonRect.Width = buttonRect.Height; // Make it square

            // Offset it
            buttonRect.Offset(-buttonRect.Width / 2, 0);
            buttonX = (int)((currentValue - minValue) * (float)boundingBox.Width / (maxValue - minValue) );
            buttonRect.Offset(buttonX, 0);
        }
예제 #32
0
        /// <summary>Stores data for a combo box item</summary>
        public override bool HandleMouse(NativeMethods.WindowMessage msg, System.Drawing.Point pt, IntPtr wParam, IntPtr lParam)
        {
            if (!IsEnabled || !IsVisible)
                return false;

            switch(msg)
            {
                case NativeMethods.WindowMessage.LeftButtonDoubleClick:
                case NativeMethods.WindowMessage.LeftButtonDown:
                {
                    NativeMethods.SetCapture(Parent.SampleFramework.Window);

                    // Check for on up button
                    if (upButtonRect.Contains(pt))
                    {
                        if (position > start)
                            --position;
                        UpdateThumbRectangle();
                        return true;
                    }

                    // Check for on down button
                    if (downButtonRect.Contains(pt))
                    {
                        if (position + pageSize < end)
                            ++position;
                        UpdateThumbRectangle();
                        return true;
                    }

                    // Check for click on thumb
                    if (thumbRect.Contains(pt))
                    {
                        isDragging = true;
                        thumbOffsetY = pt.Y - thumbRect.Top;
                        return true;
                    }

                    // check for click on track
                    if (thumbRect.Left <= pt.X &&
                        thumbRect.Right > pt.X)
                    {
                        if (thumbRect.Top > pt.Y &&
                            trackRect.Top <= pt.Y)
                        {
                            Scroll(-(pageSize-1));
                            return true;
                        }
                        else if (thumbRect.Bottom <= pt.Y &&
                            trackRect.Bottom > pt.Y)
                        {
                            Scroll(pageSize-1);
                            return true;
                        }
                    }

                    break;
                }
                case NativeMethods.WindowMessage.LeftButtonUp:
                {
                    isDragging = false;
                    NativeMethods.ReleaseCapture();
                    UpdateThumbRectangle();
                    break;
                }

                case NativeMethods.WindowMessage.MouseMove:
                {
                    if (isDragging)
                    {
                        // Calculate new bottom and top of thumb rect
                        int bottom = thumbRect.Bottom + (pt.Y - thumbOffsetY - thumbRect.Top);
                        int top = pt.Y - thumbOffsetY;
                        thumbRect = new System.Drawing.Rectangle(thumbRect.Left, top, thumbRect.Width, bottom - top);
                        if (thumbRect.Top < trackRect.Top)
                            thumbRect.Offset(0, trackRect.Top - thumbRect.Top);
                        else if (thumbRect.Bottom > trackRect.Bottom)
                            thumbRect.Offset(0, trackRect.Bottom - thumbRect.Bottom);

                        // Compute first item index based on thumb position
                        int maxFirstItem = end - start - pageSize; // Largest possible index for first item
                        int maxThumb = trackRect.Height - thumbRect.Height; // Largest possible thumb position

                        position = start + (thumbRect.Top - trackRect.Top +
                            maxThumb / (maxFirstItem * 2) ) * // Shift by half a row to avoid last row covered
                            maxFirstItem / maxThumb;

                        return true;
                    }
                    break;
                }
            }

            // Was not handled
            return false;
        }
예제 #33
0
        /// <summary>Render the dialog</summary>
        public void OnRender(float elapsedTime)
        {
            // See if the dialog needs to be refreshed
            if (timeLastRefresh < timeRefresh)
            {
                timeLastRefresh = FrameworkTimer.GetTime();
                Refresh();
            }

            Device device = DialogResourceManager.GetGlobalInstance().Device;

            // Set up a state block here and restore it when finished drawing all the controls
            DialogResourceManager.GetGlobalInstance().StateBlock.Capture();

            // Set some render/texture states
            device.RenderState.AlphaBlendEnable = true;
            device.RenderState.SourceBlend = Blend.SourceAlpha;
            device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
            device.RenderState.AlphaTestEnable = false;
            device.TextureState[0].ColorOperation = TextureOperation.SelectArg2;
            device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
            device.TextureState[0].AlphaOperation = TextureOperation.SelectArg1;
            device.TextureState[0].AlphaArgument1 = TextureArgument.Diffuse;
            device.RenderState.ZBufferEnable = false;
            // Clear vertex/pixel shader
            device.VertexShader = null;
            device.PixelShader = null;

            // Render if not minimized
            if (!isDialogMinimized)
            {
                device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
                device.DrawUserPrimitives(PrimitiveType.TriangleFan, 2, vertices);
            }

            // Reset states
            device.TextureState[0].ColorOperation = TextureOperation.Modulate;
            device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
            device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
            device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
            device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            device.TextureState[0].AlphaArgument2 = TextureArgument.Diffuse;

            device.SamplerState[0].MinFilter = TextureFilter.Linear;

            // Set the texture up, and begin the sprite
            TextureNode tNode = GetTexture(0);
            device.SetTexture(0, tNode.Texture);
            DialogResourceManager.GetGlobalInstance().Sprite.Begin(SpriteFlags.DoNotSaveState);

            // Render the caption if it's enabled.
            if (hasCaption)
            {
                // DrawSprite will offset the rect down by
                // captionHeight, so adjust the rect higher
                // here to negate the effect.
                System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0,-captionHeight,width,0);
                DrawSprite(captionElement, rect);
                rect.Offset(5, 0); // Make a left margin
                string output = caption + ((isDialogMinimized) ? " (Minimized)" : null);
                DrawText(output, captionElement, rect, true);
            }

            // If the dialog is minimized, skip rendering
            // its controls.
            if (!isDialogMinimized)
            {
                for(int i = 0; i < controlList.Count; i++)
                {
                    // Focused control is drawn last
                    if (controlList[i] == controlFocus)
                        continue;

                    (controlList[i] as Control).Render(device, elapsedTime);
                }

                // Render the focus control if necessary
                if (controlFocus != null && controlFocus.Parent == this)
                    controlFocus.Render(device, elapsedTime);
            }

            // End the sprite and apply the stateblock
            DialogResourceManager.GetGlobalInstance().Sprite.End();
            DialogResourceManager.GetGlobalInstance().StateBlock.Apply();
        }
예제 #34
0
        /// <summary>Update the rectangles for the combo box control</summary>
        protected override void UpdateRectangles()
        {
            // Get bounding box
            base.UpdateRectangles();

            // Update the bounding box for the items
            buttonRect = new System.Drawing.Rectangle(boundingBox.Right - boundingBox.Height, boundingBox.Top,
                boundingBox.Height, boundingBox.Height);

            textRect = boundingBox;
            textRect.Size = new System.Drawing.Size(textRect.Width - buttonRect.Width, textRect.Height);

            dropDownRect = textRect;
            dropDownRect.Offset(0, (int)(0.9f * textRect.Height));
            dropDownRect.Size = new System.Drawing.Size(dropDownRect.Width - scrollWidth, dropDownRect.Height + dropHeight);

            // Scale it down slightly
            System.Drawing.Point loc = dropDownRect.Location;
            System.Drawing.Size size = dropDownRect.Size;

            loc.X += (int)(0.1f * dropDownRect.Width);
            loc.Y += (int)(0.1f * dropDownRect.Height);
            size.Width -= (2 * (int)(0.1f * dropDownRect.Width));
            size.Height -= (2 * (int)(0.1f * dropDownRect.Height));

            dropDownTextRect = new System.Drawing.Rectangle(loc, size);

            // Update the scroll bars rects too
            scrollbarControl.SetLocation(dropDownRect.Right, dropDownRect.Top + 2);
            scrollbarControl.SetSize(scrollWidth, dropDownRect.Height - 2);
            FontNode fNode = DialogResourceManager.GetGlobalInstance().GetFontNode((int)(elementList[2] as Element).FontIndex);
            if ((fNode != null) && (fNode.Height > 0))
            {
                scrollbarControl.PageSize = (int)(dropDownTextRect.Height / fNode.Height);

                // The selected item may have been scrolled off the page.
                // Ensure that it is in page again.
                scrollbarControl.ShowItem(selectedIndex);
            }
        }
 public Region CompensateRegionPosition(Region region, double pixelRatio)
 {
     System.Drawing.Rectangle rect = region.ToRectangle();
     rect.Offset(0, (int)Math.Floor(pixelRatio - 0.0001));
     return(new Region(rect));
 }