RectangleToScreen() public method

public RectangleToScreen ( Rectangle r ) : Rectangle
r Rectangle
return Rectangle
Example #1
1
 public static Control FindTopControl(Control parent, Point screen_pt)
 {
     Control c = parent.GetChildAtPoint(parent.PointToClient(screen_pt));
     if (c == null) {
         if (parent.RectangleToScreen(new Rectangle(0, 0, parent.Width, parent.Height)).Contains(screen_pt))
             return parent;
         else
             return null;
     }
     else
         return FindTopControl(c, screen_pt);
 }
Example #2
0
 void Show(string title, string text, Control control, ICON icon = 0, double timeOut = 0, bool allowMulti = false, bool focus = false, short x = 0, short y = 0)
 {
     if (!allowMulti)
         CloseAll();
     if (x == 0 && y == 0)
     {
         x = (short)(control.RectangleToScreen(control.ClientRectangle).Left + control.Width / 2);
         y = (short)(control.RectangleToScreen(control.ClientRectangle).Top + control.Height / 2);
     }
     TOOLINFO toolInfo = new TOOLINFO();
     toolInfo.cbSize = (uint)Marshal.SizeOf(toolInfo);
     toolInfo.uFlags = 0x20; // TTF_TRACK
     toolInfo.lpszText = text;
     IntPtr pToolInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(toolInfo));
     Marshal.StructureToPtr(toolInfo, pToolInfo, false);
     byte[] buffer = Encoding.UTF8.GetBytes(title);
     buffer = buffer.Concat(new byte[] { 0 }).ToArray();
     IntPtr pszTitle = Marshal.AllocCoTaskMem(buffer.Length);
     Marshal.Copy(buffer, 0, pszTitle, buffer.Length);
     hWnd = User32.CreateWindowEx(0x8, "tooltips_class32", "", 0xC3, 0, 0, 0, 0, control.Parent.Handle, (IntPtr)0, (IntPtr)0, (IntPtr)0);
     User32.SendMessage(hWnd, 1028, (IntPtr)0, pToolInfo); // TTM_ADDTOOL
     User32.SendMessage(hWnd, 1042, (IntPtr)0, (IntPtr)((ushort)x | ((ushort)y << 16))); // TTM_TRACKPOSITION
     //User32.SendMessage(hWnd, 1043, (IntPtr)0, (IntPtr)0); // TTM_SETTIPBKCOLOR
     //User32.SendMessage(hWnd, 1044, (IntPtr)0xffff, (IntPtr)0); // TTM_SETTIPTEXTCOLOR
     User32.SendMessage(hWnd, 1056, (IntPtr)icon, pszTitle); // TTM_SETTITLE 0:None, 1:Info, 2:Warning, 3:Error, >3:assumed to be an hIcon. ; 1057 for Unicode
     User32.SendMessage(hWnd, 1048, (IntPtr)0, (IntPtr)500); // TTM_SETMAXTIPWIDTH
     User32.SendMessage(hWnd, 0x40c, (IntPtr)0, pToolInfo); // TTM_UPDATETIPTEXT; 0x439 for Unicode
     User32.SendMessage(hWnd, 1041, (IntPtr)1, pToolInfo); // TTM_TRACKACTIVATE
     Marshal.FreeCoTaskMem(pszTitle);
     Marshal.DestroyStructure(pToolInfo, typeof(TOOLINFO));
     Marshal.FreeCoTaskMem(pToolInfo);
     if (focus)
         control.Focus();
     control.Enter += control_Event;
     control.Leave += control_Event;
     control.TextChanged += control_Event;
     control.KeyPress += control_Event;
     control.Click += control_Event;
     control.LocationChanged += control_Event;
     control.SizeChanged += control_Event;
     control.VisibleChanged += control_Event;
     if (control is DataGridView)
         ((DataGridView)control).CellBeginEdit += control_Event;
     Control parent = control.Parent;
     while(parent != null)
     {
         parent.VisibleChanged += control_Event;
         parent = parent.Parent;
     }
     control.TopLevelControl.LocationChanged += control_Event;
     ((Form)control.TopLevelControl).Deactivate += control_Event;
     timer.AutoReset = false;
     timer.Elapsed += timer_Elapsed;
     if (timeOut > 0)
     {
         timer.Interval = timeOut;
         timer.Start();
     }
 }
Example #3
0
    /*******************************/
    /// <summary>
    /// This method returns an Array of System.Int32 containing the size of the non client area of a control.
    /// The non client area includes elements such as scroll bars, borders, title bars, and menus.
    /// </summary>
    /// <param name="control">The control from which to retrieve the values.</param>
    /// <returns>An Array of System.Int32 containing the width of each non client area border in the following order
    /// top, left, right and bottom.</returns>
    public static System.Int32[] GetInsets(System.Windows.Forms.Control control)
    {
        System.Int32[] returnValue = new System.Int32[4];

        returnValue[0] = (control.RectangleToScreen(control.ClientRectangle).Top - control.Bounds.Top);
        returnValue[1] = (control.RectangleToScreen(control.ClientRectangle).Left - control.Bounds.Left);
        returnValue[2] = (control.Bounds.Right - control.RectangleToScreen(control.ClientRectangle).Right);
        returnValue[3] = (control.Bounds.Bottom - control.RectangleToScreen(control.ClientRectangle).Bottom);
        return(returnValue);
    }
Example #4
0
 public static Rectangle getVisibleRectangle(Control panel, Control insideControl)
 {
     Rectangle rect = panel.RectangleToScreen(panel.ClientRectangle);
     while (panel != null)
     {
         rect = Rectangle.Intersect(rect, panel.RectangleToScreen(panel.ClientRectangle));
         panel = panel.Parent;
     }
     rect = insideControl.RectangleToClient(rect);
     return rect;
 }
Example #5
0
 public Rubberband(System.Windows.Forms.Control theParent, Point theStartingPoint)
 {
     parent = theParent;
     parent.Capture = true;
     Cursor.Clip = parent.RectangleToScreen(parent.ClientRectangle);
     rect = new Rectangle(theStartingPoint.X, theStartingPoint.Y, 0, 0);
 }
Example #6
0
 internal static Rect GetControlScreenBounds(Rectangle bounds, SWF.Control control, bool controlIsParent)
 {
     if (control == null || !control.Visible)
     {
         return(Rect.Empty);
     }
     else if (controlIsParent)
     {
         return(Helper.RectangleToRect(control.RectangleToScreen(bounds)));
     }
     else if (control.Parent == null || control.TopLevelControl == null)
     {
         return(Helper.RectangleToRect(bounds));
     }
     else
     {
         if (control.FindForm() == control.Parent)
         {
             return(Helper.RectangleToRect(control.TopLevelControl.RectangleToScreen(bounds)));
         }
         else
         {
             return(Helper.RectangleToRect(control.Parent.RectangleToScreen(bounds)));
         }
     }
 }
Example #7
0
        /// <summary>
        /// Get preview bounds
        /// </summary>
        /// <param name="dock">dock for which to get the preview bounds</param>
        /// <param name="movedPanel">moved panel</param>
        /// <param name="panelUnderMouse">panel under mouse</param>
        /// <param name="freeAreaBounds">free area bounds</param>
        /// <returns>preview bounds</returns>
        public static Rectangle GetPreviewBounds(DockStyle dock, Control movedPanel, Control panelUnderMouse, Rectangle freeAreaBounds)
        {
            Rectangle bounds = freeAreaBounds;
             if (panelUnderMouse != null)
             {
            bounds = panelUnderMouse.RectangleToScreen(panelUnderMouse.ClientRectangle);
             }

             switch (dock)
             {
            case DockStyle.Left:
               return GetInnerLeftPreviewBounds(movedPanel, bounds);

            case DockStyle.Right:
               return GetInnerRightPreviewBounds(movedPanel, bounds);

            case DockStyle.Top:
               return GetInnerTopPreviewBounds(movedPanel, bounds);

            case DockStyle.Bottom:
               return GetInnerBottomPreviewBounds(movedPanel, bounds);

            case DockStyle.Fill:
               return GetInnerFillPreviewBounds(movedPanel, bounds);

            default:
               throw new InvalidOperationException();
             }
        }
Example #8
0
        // xpos = +1 right, -1 left, 0 centre ypos = +1 top -1 bot 0 centre of parent
        // yoffper xoffper =  percentage of parent width to shift from indicated pos, can be negative
        // widthper/heightper = percentage of parent width, or 0 to measure string and fit
        public void Position(Control parent, int xpos, int xoffper, int ypos, int yoffper , int widthper, int heightper )
        {
            Rectangle loc = parent.RectangleToScreen( parent.ClientRectangle);

            if (widthper == 0 || heightper == 0)
            {
                using (Graphics g = CreateGraphics())
                {
                    SizeF sizef = g.MeasureString(labelMessage.Text, labelMessage.Font);

                    Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle);
                    int titleHeight = screenRectangle.Top - this.Top;

                    Size = new Size((int)(sizef.Width + 16), (int)(sizef.Height + titleHeight + 16));
                }
            }
            else
                Size = new Size(loc.Width * widthper / 100, loc.Height * heightper / 100);

            int xref = (xpos < 0) ? loc.Left : ((xpos > 0) ? loc.Right : (loc.X + loc.Width / 2));
            int yref = (ypos < 0) ? loc.Bottom: ((ypos > 0) ? loc.Top : (loc.Y + loc.Height / 2));

            xref += loc.Width * xoffper / 100;
            yref += loc.Height * yoffper / 100;

            Location = new Point(xref - Width / 2, yref - Height / 2);

            labelMessage.Size = new Size(ClientRectangle.Width - 8, ClientRectangle.Height - 8);
        }
Example #9
0
            private void PaintBackground(Graphics g, Control control, Rectangle clipRect)
            {
                Control parent = control;
                IPaintBackground asIpb = null;

                while (true)
                {
                    parent = parent.Parent;

                    if (parent == null)
                    {
                        break;
                    }

                    asIpb = parent as IPaintBackground;

                    if (asIpb != null)
                    {
                        break;
                    }
                }

                if (asIpb != null)
                {
                    Rectangle screenRect = control.RectangleToScreen(clipRect);
                    Rectangle parentRect = parent.RectangleToClient(screenRect);

                    int dx = parentRect.Left - clipRect.Left;
                    int dy = parentRect.Top - clipRect.Top;

                    g.TranslateTransform(-dx, -dy, MatrixOrder.Append);
                    asIpb.PaintBackground(g, parentRect);
                    g.TranslateTransform(dx, dy, MatrixOrder.Append);
                }
            }
        //draws a BitMap of the control
        private Bitmap DrawGridToBitmap(System.Windows.Forms.Control control)
        {
            Bitmap    bitmap    = new Bitmap(control.Width, control.Height);
            Graphics  graphics  = Graphics.FromImage(bitmap);
            Rectangle rectangle = control.RectangleToScreen(control.ClientRectangle);

            graphics.CopyFromScreen(rectangle.Location, Point.Empty, control.Size);
            return(bitmap);
        }
Example #11
0
        public Dragger(Control theParent, Control theItemsToDrag, Point theStartingPoint)
        {
            parent = theParent;
            ctr = theItemsToDrag;
            location = theStartingPoint;
            current = location;

            // parent.Capture   =   true;
            Cursor.Clip = parent.RectangleToScreen(parent.ClientRectangle);
        }
Example #12
0
        }                                                                       // end method Control

        /// <summary>
        /// Captures the specified area of the control or whats underneath
        /// the control. If the argument flag client is true, only the client
        /// area of the control is captured, otherwise the entire control is
        /// captured. If the argument flag under is true, the capture area under
        /// the control is captured, otherwise the specified area on the control
        /// is captured.
        /// </summary>
        /// <param name="ctl">Control to capture</param>
        /// <param name="client">If true capture only client area else entire control.</param>
        /// <param name="under">If true capture specified area underneath the control else whats on the control.</param>
        /// <returns>bitmap image of the control or whats underneath the control</returns>
        public static Bitmap    Control(System.Windows.Forms.Control ctl, bool client, bool under)
        {
            Bitmap    bmp;                                                                      // capture bitmap
            Rectangle ctlR;                                                                     // capture area rectangle in control coordinates
            Rectangle scrR;                                                                     // capture area rectangle in screen coordinates

            //	get capture rectangle in control
            //	coordinates and in screen coordinates
            if (client)                                                         // if capturing client area
            {
                ctlR = ctl.ClientRectangle;                                     //   get rectangle in control coordinates
                scrR = ctl.RectangleToScreen(ctlR);                             //   get rectangle in screen coordinates
            }
            else                                                                // if capturing entire control
            {
                scrR = ctl.Bounds;                                              //   get rectangle in parent coordinates
                if (ctl.Parent != null)                                         //   if parent exists
                {
                    scrR = ctl.Parent.RectangleToScreen(scrR);                  //     map to screen coordinates
                }
                ctlR = ctl.RectangleToClient(scrR);                             //   get rectangle in control coordinates
            }

            //	capture an area under the control
            if (under)                                                                  // if capture area is under control
            {
                bool prvV = ctl.Visible;                                                //   save control visibility
                if (prvV)                                                               //   if control visible
                {
                    ctl.Visible = false;                                                //     make control invisible
                    Thread.Sleep(m_HDelay);                                             //     allow time for control to become invisible
                    //     prior to image capture
                }

                //	Capture the bitmap using desktop window handle and screen coordinates
                //	for the capture area. Note, the control window handle can NOT be used
                //  for capturing an area under the control.
                IntPtr desktopHWND = USER32.GetDesktopWindow();                         // get window handle for desktop
                bmp = Window(desktopHWND, scrR);                                        // get bitmap for capture area under control
                if (ctl.Visible != prvV)                                                //   if control visibility was changed
                {
                    ctl.Visible = prvV;                                                 //     restore previous visibility
                }
            }

            //	capture an area on the control
            else                                                                                        // if capture area not under control
            {
                //	Capture the bitmap using control window handle and control coordinates
                //	for capture area.
                bmp = Window(ctl.Handle, ctlR);                                 //   get bitmap using control window handle
            }
            return(bmp);                                                        // return requested bitmap
        }                                                                       // end method Control
Example #13
0
        // 진행 팝업창을 띄움
        public static void LoadIngPopUpShow(System.Windows.Forms.Control parent)
        {
            if (loading == null)
            {
                loading = new LoadingPopUp();
            }

            Rectangle pos = parent.RectangleToScreen(parent.ClientRectangle);

            loading.Location = new Point(pos.Left + pos.Width / 2 - loading.Size.Width / 2, pos.Top + pos.Height / 2 - loading.Size.Height / 2);
            loading.Show();
            loading.Focus();
        }
        /// <summary>
        /// Initialize a new instance of the ControlObscurer class.
        /// </summary>
        /// <param name="c">Control to obscure.</param>
        /// <param name="designMode">Is the source in design mode.</param>
        public ScreenObscurer(Control c, bool designMode)
        {
            // Check the incoming control is valid
            if ((c != null) && !c.IsDisposed && !designMode)
            {
                // First time needed, create the top level obscurer window
                if (_obscurer == null)
                    _obscurer = new ObscurerForm();

                // We need a control to work with!
                if (c != null)
                    _obscurer.ShowForm(c.RectangleToScreen(c.ClientRectangle));
            }
        }
Example #15
0
        /// <summary>
        /// Excludes a Control from the AeroGlass frame.
        /// </summary>
        /// <param name="control">The control to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not 
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeControlFromAeroGlass( Control control )
        {
            if( AeroGlassCompositionEnabled )
            {
                Rectangle clientScreen = this.RectangleToScreen( this.ClientRectangle );
                Rectangle controlScreen = control.RectangleToScreen( control.ClientRectangle );

                MARGINS margins = new MARGINS( );
                margins.cxLeftWidth = controlScreen.Left - clientScreen.Left;
                margins.cxRightWidth = clientScreen.Right - controlScreen.Right;
                margins.cyTopHeight = controlScreen.Top - clientScreen.Top;
                margins.cyBottomHeight = clientScreen.Bottom - controlScreen.Bottom;

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea( Handle, ref margins );
            }
        }
        /// <summary>
        /// Excludes a Control from the AeroGlass frame.
        /// </summary>
        /// <param name="control">The control to exclude.</param>
        /// <remarks>Many non-WPF rendered controls (i.e., the ExplorerBrowser control) will not 
        /// render properly on top of an AeroGlass frame. </remarks>
        public void ExcludeControlFromAeroGlass(Control control)
        {
            if (control == null) { throw new ArgumentNullException(nameof(control)); }

            if (AeroGlassCompositionEnabled)
            {
                Rectangle clientScreen = this.RectangleToScreen(this.ClientRectangle);
                Rectangle controlScreen = control.RectangleToScreen(control.ClientRectangle);

                Margins margins = new Margins();
                margins.LeftWidth = controlScreen.Left - clientScreen.Left;
                margins.RightWidth = clientScreen.Right - controlScreen.Right;
                margins.TopHeight = controlScreen.Top - clientScreen.Top;
                margins.BottomHeight = clientScreen.Bottom - controlScreen.Bottom;

                // Extend the Frame into client area
                DesktopWindowManagerNativeMethods.DwmExtendFrameIntoClientArea(Handle, ref margins);
            }
        }
Example #17
0
        public static System.Windows.Rect GetBounds(SWF.MenuItem item)
        {
            SWF.Menu    parentMenu;
            SWF.Control wnd = GetWnd(item, out parentMenu);

            if (wnd == null)
            {
                return(System.Windows.Rect.Empty);
            }

            System.Drawing.Rectangle rect       = item.bounds;
            System.Windows.Rect      returnRect =
                Helper.RectangleToRect(wnd.RectangleToScreen(rect));
            if (item.Parent == parentMenu)
            {
                returnRect.Y -= returnRect.Height;
            }
            return(returnRect);
        }
Example #18
0
 public static string Show(Control owner)
 {
     if (owner == null)
         throw new Exception("owner is null!");
     Self._owner = owner;
     int xPos = owner.RectangleToScreen(Rectangle.Empty).X;
     int yPos = owner.RectangleToScreen(Rectangle.Empty).Y + Self._owner.Height + 5;
     Self.TopMost = true;
     if (!Self.Visible)
         Self.Show();
     Self.Location = new Point(xPos, yPos);
     owner.Select();
     return string.Empty;
 }
Example #19
0
 /// <summary>
 /// Gets the client rectangle of given form
 /// </summary>
 /// <param name="form">form object</param>
 /// <returns>client rectangle for given form</returns>
 public static Rectangle GetScreenClientRectangle(Control form)
 {
    return form.RectangleToScreen(form.ClientRectangle);
 }
Example #20
0
 /// <summary>
 /// Функция нормализует Rectangle Control (form)
 /// </summary>
 /// <param name="owner">Элемент под которым размещаемся!</param>
 /// <param name="slave">Элемент, который размещаем!</param>
 /// <returns></returns>
 public static Rectangle GetBoundsControl(Control Owner,Control slave)
 {
     return GetBoundsControl(Owner.RectangleToScreen(Owner.Bounds),slave);
 }
        private static void DrawXorBar(Control ctlDrawTo, Rectangle rcFrame) {
            Rectangle rc = ctlDrawTo.RectangleToScreen(rcFrame);

            if (rc.Width < rc.Height) {
                for (int i = 0; i < rc.Width; i++) {
                    ControlPaint.DrawReversibleLine(new Point(rc.X+i, rc.Y), new Point(rc.X+i, rc.Y+rc.Height), ctlDrawTo.BackColor);
                }
            }
            else {
                for (int i = 0; i < rc.Height; i++) {
                    ControlPaint.DrawReversibleLine(new Point(rc.X, rc.Y+i), new Point(rc.X+rc.Width, rc.Y+i), ctlDrawTo.BackColor);
                }
            }
        }
Example #22
0
		public void PubMethodTest7()
		{
			Control r1 = new Control();
			r1.RightToLeft = RightToLeft.Yes ;
			r1.ResetRightToLeft() ;
			Assert.AreEqual(RightToLeft.No , r1.RightToLeft , "#81");
			r1.ImeMode = ImeMode.Off ;
			r1.ResetImeMode () ;
			Assert.AreEqual(ImeMode.NoControl , r1.ImeMode , "#82");
			r1.ForeColor= SystemColors.GrayText ;
			r1.ResetForeColor() ;
			Assert.AreEqual(SystemColors.ControlText , r1.ForeColor , "#83");
			//r1.Font = Font.FromHdc();
			r1.ResetFont () ;
			//Assert.AreEqual(FontFamily.GenericSansSerif , r1.Font , "#83");
			r1.Cursor = Cursors.Hand ;
			r1.ResetCursor () ;
			Assert.AreEqual(Cursors.Default , r1.Cursor , "#83");
			//r1.DataBindings = System.Windows.Forms.Binding ;
			//r1.ResetBindings() ;
			//Assert.AreEqual(ControlBindingsCollection , r1.DataBindings  , "#83");
			r1.BackColor = Color.Black ;
			r1.ResetBackColor() ;
			Assert.AreEqual( SystemColors.Control , r1.BackColor  , "#84");
			r1.BackColor = Color.Black ;
			r1.Refresh() ;
			Assert.AreEqual( null , r1.Region , "#85");
			Rectangle M = new Rectangle(10, 20, 30 ,40);
			r1.RectangleToScreen(M) ;
			Assert.AreEqual( null , r1.Region , "#86");
		}
Example #23
0
 public static object CallControlRectangleToScreen(Control c, object[] obj)
 {
     return(c.RectangleToScreen((System.Drawing.Rectangle)obj[0]));
 }
Example #24
0
        private void DrawStart(Point StartPoint, Control tab)
        {
            tab.Capture = true;
            Cursor.Clip = tab.RectangleToScreen(new Rectangle(0, 0, tab.Width, tab.Height));

            MouseRect = new Rectangle(StartPoint.X, StartPoint.Y, 0, 0);
        }
        /// <summary>
        /// Display the dropdown and adjust its size and location
        /// </summary>
        public void Show(Control opener, Size preferredSize = new Size())
        {
            if (opener == null)
            {
                throw new ArgumentNullException("opener");
            }

            m_opener = opener;

            int w = preferredSize.Width == 0 ? ClientRectangle.Width : preferredSize.Width;
            int h = preferredSize.Height == 0 ? Content.Height : preferredSize.Height;
            h += Padding.Size.Height + Content.Margin.Size.Height;

            Rectangle screen = Screen.FromControl(m_opener).WorkingArea;

            // let's try first to place it below the opener control
            Rectangle loc = m_opener.RectangleToScreen(
                new Rectangle(m_opener.ClientRectangle.Left, m_opener.ClientRectangle.Bottom,
                    m_opener.ClientRectangle.Left + w, m_opener.ClientRectangle.Bottom + h));
            Point cloc = new Point(m_opener.ClientRectangle.Left, m_opener.ClientRectangle.Bottom);
            if (!screen.Contains(loc))
            {
                // let's try above the opener control
                loc = m_opener.RectangleToScreen(
                    new Rectangle(m_opener.ClientRectangle.Left, m_opener.ClientRectangle.Top - h,
                        m_opener.ClientRectangle.Left + w, m_opener.ClientRectangle.Top));
                if (screen.Contains(loc))
                {
                    cloc = new Point(m_opener.ClientRectangle.Left, m_opener.ClientRectangle.Top - h);
                }
            }
            Width = w;
            Height = h;
            Show(m_opener, cloc, ToolStripDropDownDirection.BelowRight);
        }
Example #26
0
		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateControl ()
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			Control c = new Control ();
			
			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			c.Contains (new Control ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			c.CreateControl ();
			Assert.IsTrue (c.IsHandleCreated, "A3");
			c = new Control ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c = new Control ();
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Control ();
			//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
			//Assert.IsFalse (c.IsHandleCreated, "A6");
			//Assert.AreEqual (DragDropEffects.None, d, "A6b");
			//Bitmap b = new Bitmap (100, 100);
			//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
			//Assert.IsFalse (c.IsHandleCreated, "A7");
			//b.Dispose ();
			c.FindForm ();
			Assert.IsFalse (c.IsHandleCreated, "A8");
			c.Focus ();
			Assert.IsFalse (c.IsHandleCreated, "A9");

			c.GetChildAtPoint (new Point (10, 10));
			Assert.IsTrue (c.IsHandleCreated, "A10");
			c.GetContainerControl ();
			c = new Control ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
#if NET_2_0
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
#endif
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "A14");
			c.Invalidate ();
			Assert.IsFalse (c.IsHandleCreated, "A15");
			//c.Invoke (new InvokeDelegate (InvokeMethod));
			//Assert.IsFalse (c.IsHandleCreated, "A16");
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A17");
			c.PointToClient (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A18");
			c = new Control ();
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c = new Control ();
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c = new Control ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c = new Control ();
			c.Refresh ();
			Assert.IsFalse (c.IsHandleCreated, "A22");
			c.ResetBackColor ();
			Assert.IsFalse (c.IsHandleCreated, "A23");
			c.ResetBindings ();
			Assert.IsFalse (c.IsHandleCreated, "A24");
			c.ResetCursor ();
			Assert.IsFalse (c.IsHandleCreated, "A25");
			c.ResetFont ();
			Assert.IsFalse (c.IsHandleCreated, "A26");
			c.ResetForeColor ();
			Assert.IsFalse (c.IsHandleCreated, "A27");
			c.ResetImeMode ();
			Assert.IsFalse (c.IsHandleCreated, "A28");
			c.ResetRightToLeft ();
			Assert.IsFalse (c.IsHandleCreated, "A29");
			c.ResetText ();
			Assert.IsFalse (c.IsHandleCreated, "A30");
			c.SuspendLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A31");
			c.ResumeLayout ();
			Assert.IsFalse (c.IsHandleCreated, "A32");
#if NET_2_0
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
#endif
			c.Select ();
			Assert.IsFalse (c.IsHandleCreated, "A34");
			c.SelectNextControl (new Control (), true, true, true, true);
			Assert.IsFalse (c.IsHandleCreated, "A35");
			c.SetBounds (0, 0, 100, 100);
			Assert.IsFalse (c.IsHandleCreated, "A36");
			c.Update ();
			Assert.IsFalse (c.IsHandleCreated, "A37");
		}
                /// <summary>
                /// 
                /// </summary>
                /// <param name="e"></param>
                /// <param name="ctr"></param>
                /// <param name="lastKeyEventArgs"></param>
                public override bool DoMouseMove(MouseEventArgs e, Control ctr, KeyEventArgs lastKeyEventArgs)
                {
                    NPlot.PlotSurface2D ps = ((Windows.PlotSurface2D)ctr).Inner;

                    // if mouse isn't in plot region, then don't draw horizontal line
                    if (e.X > ps.PlotAreaBoundingBoxCache.Left && e.X < (ps.PlotAreaBoundingBoxCache.Right-1) &&
                        e.Y > ps.PlotAreaBoundingBoxCache.Top && e.Y < ps.PlotAreaBoundingBoxCache.Bottom)
                    {
                        if (ps.PhysicalXAxis1Cache != null)
                        {

                            // the clipping rectangle in screen coordinates
                            Rectangle clip = ctr.RectangleToScreen(
                                new Rectangle(
                                (int)ps.PlotAreaBoundingBoxCache.X,
                                (int)ps.PlotAreaBoundingBoxCache.Y,
                                (int)ps.PlotAreaBoundingBoxCache.Width,
                                (int)ps.PlotAreaBoundingBoxCache.Height));

                            Point p = ctr.PointToScreen(new Point(e.X, e.Y));

                            if (barPos_ != -1)
                            {
                                ControlPaint.DrawReversibleLine(
                                    new Point(barPos_, clip.Top),
                                    new Point(barPos_, clip.Bottom), color_);
                            }

                            if (p.X < clip.Right && p.X > clip.Left)
                            {
                                ControlPaint.DrawReversibleLine(
                                    new Point(p.X, clip.Top),
                                    new Point(p.X, clip.Bottom), color_);
                                barPos_ = p.X;
                            }
                            else
                            {
                                barPos_ = -1;
                            }
                        }
                    }
                    else
                    {
                        if (barPos_ != -1)
                        {

                            Rectangle clip = ctr.RectangleToScreen(
                                new Rectangle(
                                    (int)ps.PlotAreaBoundingBoxCache.X,
                                    (int)ps.PlotAreaBoundingBoxCache.Y,
                                    (int)ps.PlotAreaBoundingBoxCache.Width,
                                    (int)ps.PlotAreaBoundingBoxCache.Height)
                                );

                            ControlPaint.DrawReversibleLine(
                                new Point(barPos_, clip.Top),
                                new Point(barPos_, clip.Bottom), color_);

                            barPos_ = -1;
                        }
                    }

                    return false;
                }
		/// <summary>
		/// </summary>
		/// <param name="targetControl">If <see langword="null"/> tooltip location is calculated according to <paramref name="cursorPosition"/> and <paramref name="cursorSize"/> only.</param>
		/// <param name="cursorPosition">Screen coordinates expected.</param>
		/// <param name="cursorSize"></param>
		/// <param name="placeBelowControl"></param>
		/// <returns></returns>
		public Point GetToolTipLocation(Control targetControl, Point cursorPosition, Size cursorSize, bool placeBelowControl)
		{
			Point tooltipLocation;

			if (targetControl != null && placeBelowControl)
			{
				Rectangle ctrlScreenBounds = targetControl.RectangleToScreen(targetControl.ClientRectangle);
				tooltipLocation = new Point(cursorPosition.X, ctrlScreenBounds.Bottom + _tooltipOffset);
			}
			else
			{
				tooltipLocation = cursorPosition;
				tooltipLocation.Offset(cursorSize.Width / 2, cursorSize.Height / 2);
			}

			return tooltipLocation;
		}
Example #29
0
        /// <summary>
        /// Capture a specific control in the client area of a form.
        /// </summary>
        /// <param name="window">This is a control which should be captured.</param>
        /// <returns>The image which has been captured.</returns>
        public virtual Bitmap CaptureControl(System.Windows.Forms.Control window)
        {
            Rectangle rc = window.RectangleToScreen(window.DisplayRectangle);

            return(capture(window, rc));
        }
Example #30
0
 private void DrawRectangle(Control tab)
 {
     Rectangle rect = tab.RectangleToScreen(MouseRect);
     ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed);
 }
Example #31
0
 /// <summary>
 /// Capture a specific control in the client area of a form.
 /// </summary>
 /// <param name="window">This is a control which should be captured.</param>
 /// <returns>The image which has been captured.</returns>
 public virtual Bitmap CaptureControl( Control window )
 {
     Rectangle rc = window.RectangleToScreen( window.DisplayRectangle );
     return capture( window, rc );
 }
Example #32
0
 public void SetPosition( Control parent, int x, int y )
 {
     Rectangle rect = parent.RectangleToScreen(parent.ClientRectangle);
     int pt = MAKELONG(rect.Left+x, rect.Top+y);
     IntPtr ptr = new IntPtr(pt);
     SendMessage(toolwindow, TTM_TRACKPOSITION, 0, ptr);
 }
Example #33
0
        /// <summary>
        /// Excludes the specified child control from the glass effect.
        /// </summary>
        /// <param name="parent">The parent control.</param>
        /// <param name="control">The control to exclude.</param>
        /// <exception cref="ArgumentNullException">Occurs if control is null.</exception>
        /// <exception cref="ArgumentException">Occurs if control is not a child control.</exception>
        public static void ExcludeChildFromGlass(this Control parent, Control control)
        {
            if (control == null)
                throw new ArgumentNullException("control");
            if (!parent.Contains(control))
                throw new ArgumentException("Control must be a child control.");

            if (IsCompositionEnabled())
            {
                System.Drawing.Rectangle clientScreen = parent.RectangleToScreen(parent.ClientRectangle);
                System.Drawing.Rectangle controlScreen = control.RectangleToScreen(control.ClientRectangle);

                Margins margins = new Margins(controlScreen.Left - clientScreen.Left, controlScreen.Top - clientScreen.Top,
                    clientScreen.Right - controlScreen.Right, clientScreen.Bottom - controlScreen.Bottom);

                // Extend the Frame into client area
                DwmExtendFrameIntoClientArea(parent.Handle, ref margins);
            }
        }
 /// <summary>
 /// Use the obscurer to cover the provided control.
 /// </summary>
 /// <param name="c">Control to obscure.</param>
 public void Cover(Control c)
 {
     // Check the incoming control is valid
     if ((c != null) && !c.IsDisposed)
     {
         // Show over top of the provided control
         if (_obscurer != null)
             _obscurer.ShowForm(c.RectangleToScreen(c.ClientRectangle));
     }
 }
Example #35
0
        public virtual void DrawTrackerRect(Rectangle Rect, Form ClipToFrm,Graphics gs,Control frm)
        {
            Rectangle rect = Rect;
            // convert to client coordinates
            if (ClipToFrm != null)
            {
                rect=ClipToFrm.RectangleToScreen(rect);
                rect=ClipToFrm.RectangleToClient(rect);
            }

            Size size=new Size(0, 0);
            if (!m_bFinalErase)
            {
                // otherwise, size depends on the style
                if ((m_nStyle & StyleFlags.hatchedBorder)!=0)
                {
                    size.Width = size.Height = Math.Max(1, GetHandleSize(rect)-1);
                    rect.Inflate(size);
                }
                else
                {
                    size.Width = CX_BORDER;
                    size.Height = CY_BORDER;
                }
            }

            if (m_bFinalErase || !m_bErase)
            {
                Rectangle rcScreen = frm.RectangleToScreen(rect);
                Rectangle rcLast = frm.RectangleToScreen(m_rectLast);
                DrawDragRect(gs,rcScreen,rcLast);
            }
            // remember last rectangles
            m_rectLast = rect;
            m_sizeLast = size;
        }
 private static Rectangle GetPopupBounds(Control control, int height)
 {
     Rectangle rectangle = control.RectangleToScreen(control.ClientRectangle);
     Padding padding = new Padding(3);
     TextBox box = control as TextBox;
     if (box != null)
     {
         padding = new Padding((box.BorderStyle == BorderStyle.None) ? 1 : 3);
     }
     ComboBox box2 = control as ComboBox;
     if (box2 != null)
     {
         padding = new Padding(3, 3, 3 + SystemInformation.VerticalScrollBarWidth, 3);
     }
     return new Rectangle(rectangle.Left + padding.Left, rectangle.Bottom - padding.Top, rectangle.Width - padding.Horizontal, height);
 }
		public static object CallControlRectangleToScreen(Control c, object[] obj)
		{
			return c.RectangleToScreen((Rectangle)obj[0]);
		}
                /// <summary>
                /// Handler for mouse leave event
                /// </summary>
                /// <param name="e">event args</param>
                /// <param name="ctr"></param>
                /// <returns></returns>
                public override bool DoMouseLeave(EventArgs e, Control ctr, KeyEventArgs lastKeyEventArgs)
                {
                    if (barPos_ != -1)
                    {
                        NPlot.PlotSurface2D ps = ((Windows.PlotSurface2D)ctr).Inner;

                        Rectangle clip = ctr.RectangleToScreen(
                            new Rectangle(
                            (int)ps.PlotAreaBoundingBoxCache.X,
                            (int)ps.PlotAreaBoundingBoxCache.Y,
                            (int)ps.PlotAreaBoundingBoxCache.Width,
                            (int)ps.PlotAreaBoundingBoxCache.Height));

                        ControlPaint.DrawReversibleLine(
                            new Point(barPos_, clip.Top),
                            new Point(barPos_, clip.Bottom), color_);
                        barPos_ = -1;
                    }

                    return false;
                }