SetDesktopLocation() public method

public SetDesktopLocation ( int x, int y ) : void
x int
y int
return void
示例#1
0
        void RegisterQuickieText()
        {
            DockPanel.Click += (s, a) =>
            {
                var tb = new System.Windows.Forms.TextBox();
                var f  = new System.Windows.Forms.Form();

                tb.KeyDown += (kps, kpa) =>
                {
                    if (kpa.KeyCode == Keys.Escape)
                    {
                        f.Close();
                    }
                    if (kpa.KeyCode == Keys.Enter)
                    {
                        var command = tb.Text.ToLowerInvariant();
                        // Do some more intelligent stuff
                        // than this:

                        if (command.StartsWith("remove"))
                        {
                            var id = command.Split(' ')[1];
                            Hierarchy.Remove(long.Parse(id));
                        }

                        if (command == "com")
                        {
                            this.Commands.Add("Hey " + this.Commands.Count(), (n, x) => { MessageBox.Show(n.NodeDataAdapter.GetDisplayName()); }, "Nice one buddy");
                        }
                        if (command == "comr")
                        {
                            var first = this.Commands.First();
                            //  if (first != null) Hierarchy.Commands.RemoveItem(first);
                        }
                        f.Close();
                    }
                };


                tb.Width          = 300;
                tb.Font           = Consolas975;
                f.WindowState     = FormWindowState.Normal;
                f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                f.Controls.Add(tb);
                f.Show();
                f.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y);
                f.ClientSize = tb.Size;
            };
        }
示例#2
0
        public static void CenterFormOnMouse(this Form Form)
        {
            Point     MousePos = Cursor.Position;
            Rectangle R        = Screen.FromPoint(MousePos).WorkingArea;

            int X = (Cursor.Position.X - Form.Width / 2);
            int Y = (Cursor.Position.Y - Form.Height / 2);


            X = X.Limit(R.Left + 10, (R.Right - Form.Width - 10).Limit(0, R.Right - 10));
            Y = Y.Limit(R.Top + 10, (R.Bottom - Form.Height - 10).Limit(0, R.Bottom - 10));


            Form.SetDesktopLocation(X, Y);
        }
示例#3
0
 /// <summary>
 /// Position the form on the same monitor the user has put our app!
 /// </summary>
 /// <param name="f"></param>
 public void SetUpForm(Form f)
 {
     Point desktop = this.DesktopLocation;
     f.SetDesktopLocation(desktop.X + 100, desktop.Y + 100);
 }
        private void _Maximize(Form targetForm)
        {
            if (!_Fullscreen)
            {
                _Save(targetForm);

                int ScreenNr = 0;
                for (int i = 0; i < Screen.AllScreens.Length; i++)
                {
                    Screen scr = Screen.AllScreens[i];
                    int midx = targetForm.Left + targetForm.Width / 2;
                    int midy = targetForm.Top + targetForm.Height / 2;

                    if (scr.Bounds.Top <= midy && scr.Bounds.Left <= midx && scr.Bounds.Bottom >= midy && scr.Bounds.Right >= midx)
                        ScreenNr = i;
                }

                targetForm.SetDesktopLocation(Screen.AllScreens[ScreenNr].Bounds.Left, Screen.AllScreens[ScreenNr].Bounds.Top);
                targetForm.ClientSize = new Size(Screen.AllScreens[ScreenNr].Bounds.Width, Screen.AllScreens[ScreenNr].Bounds.Height);

                targetForm.FormBorderStyle = FormBorderStyle.None;
                _Fullscreen = true;
            }
        }
示例#5
0
        private void FireError(string pHost)
        {
            string error = "Something went wrong";
            switch (WmiQueryTool.WmiResults.WmiError.HResult)
            {
                case -2147023174:
                    error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nThe remote host is likely offline or having issues. Check remote IP and try again";
                    WmiQueryTool = null;
                    ScavengeStatus(pHost, false);
                    break;
                case -2147023838:
                    error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nThe Remote host appears to not be WMI capable. This can be caused by the WMI service being disabled, or the remote host not being a Windows system. Please validate remote host settings and try again";
                    WmiQueryTool = null;
                    ScavengeStatus(pHost, false);
                    break;
                case -2147024891:
                    error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nYour currently logged on user does not appear to have rights on the remote system. Please check your rights and try again. Your user may need to be added to the RDP group first";
                    WmiQueryTool = null;
                    ScavengeStatus(pHost, false);
                    break;
                default:
                    error = pHost + " " + WmiQueryTool.WmiResults.WmiError.Message.ToString() + "\r\n\r\nSomething went horribly wrong. There's an error code here. Report it to the developer, along with what you were doing so he can replicate the issue";
                    break;
            }

            if (mResultsForm == null)
            {
                mResultsForm = new Form();
                mResultsForm.FormClosed += mResultsForm_FormClosed;
                resultsTextBox = new TextBox();
                mResultsForm.Width = 615;
                mResultsForm.Height = 433;
                mResultsForm.Controls.Add(resultsTextBox);
                mResultsForm.Text = "Error Window";
                mResultsForm.MaximumSize = new Size(615, 433);
                mResultsForm.MinimumSize = new Size(615, 433);
                mResultsForm.SetDesktopLocation(0, 0);
                resultsTextBox.Location = new Point(0, 0);
                resultsTextBox.Size = new Size(600, 399);
                resultsTextBox.Multiline = true;
                resultsTextBox.ScrollBars = ScrollBars.Vertical;
                resultsTextBox.Visible = true;
                resultsTextBox.Enabled = true;
                resultsTextBox.AppendText(error + "\r\n\r\n");
            }
            else
            {
                resultsTextBox.AppendText(error + "\r\n\r\n");
            }
        }
        void IProcessCallback.TraceMemory( int memoryBytes )
        {
            if( graphPictureBox == null || graphPictureBox.Parent == null ) {
                Form form = new Form();
                form.Owner = this;
                form.Text = "Memory (Private Bytes)";
                form.FormBorderStyle = FormBorderStyle.FixedToolWindow;
                form.ShowInTaskbar = false;
                form.BackColor = Color.Black;
                graphPictureBox = new PictureBox();
                graphPictureBox.Size = form.ClientSize;
                graphPictureBox.Image = new Bitmap( graphPictureBox.ClientSize.Width, graphPictureBox.ClientSize.Height );

                using( Graphics g = Graphics.FromImage( graphPictureBox.Image ) ) {
                    for( int i = 1; i < 10; i++ ) {
                        int y = graphPictureBox.ClientSize.Height / 10 * i;
                        g.DrawLine( Pens.DarkGray,  0,  y, graphPictureBox.ClientSize.Width,  y );
                    }
                }

                form.Controls.Add( graphPictureBox );

                form.Show();
                form.SetDesktopLocation( this.DesktopLocation.X + Width, this.DesktopLocation.Y );

                counter = 0;
                prevValue = memoryBytes;
                scale = (float)( graphPictureBox.ClientSize.Height ) / memoryBytes / 2;
                return;
            }
            graphPictureBox.Parent.Show();

            const int xScale = 3;
            using( Graphics g = Graphics.FromImage( graphPictureBox.Image ) ) {
                if( prevValue * scale > graphPictureBox.ClientSize.Height ) {
                    scale = (float)( graphPictureBox.ClientSize.Height ) / prevValue / 2;
                    g.DrawLine( Pens.DarkGray,  xScale * counter,  0, xScale * counter,  graphPictureBox.ClientSize.Height );
                }
                PointF prevPoint = new PointF( xScale * counter, graphPictureBox.ClientSize.Height - prevValue * scale );
                prevValue = memoryBytes;
                PointF newPoint = new PointF( xScale * ( counter + 1 ), graphPictureBox.ClientSize.Height - prevValue * scale );
                g.DrawLine( Pens.Yellow, prevPoint, newPoint );
                prevPoint = newPoint;
            }
            graphPictureBox.Invalidate();

            counter++;
            if( ( counter + 1 ) * xScale > graphPictureBox.ClientSize.Width ) {
                counter = 0;
            }
        }
示例#7
0
 void ShowMiniProfile(object sender, JavascriptMethodEventArgs e)
 {
     try
     {
         SteamID profileId = new SteamID(Convert.ToUInt64(e.Arguments[0].ToString()));
         var miniHtml = SteamTrade.SteamWeb.Fetch("http://steamcommunity.com/miniprofile/" + profileId.AccountID);
         var file = File.ReadAllText(Application.StartupPath + "/Resources/MiniProfile.html");
         file = file.Substring(0, file.IndexOf("<body>"));
         file += "<body>" + miniHtml + "</body></html>";
         File.WriteAllText(Application.StartupPath + "/Resources/MiniProfile.html", file);
         MiniProfile.Close();
         MiniProfile = new Form();
         MiniProfile.Width = 300;
         MiniProfile.Height = 144;
         MiniProfile.ShowInTaskbar = false;
         MiniProfile.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
         MiniProfile.ControlBox = false;
         var webControlMini = new Awesomium.Windows.Forms.WebControl();
         webControlMini.DocumentReady += (sen, ev) => webControlMini_DocumentReady(sen, ev, MiniProfile);
         webControlMini.Enabled = false;
         webControlMini.Dock = DockStyle.Fill;
         webControlMini.Source = (Application.StartupPath + "/Resources/MiniProfile.html").ToUri();
         MiniProfile.Controls.Add(webControlMini);
         MiniProfile.StartPosition = FormStartPosition.Manual;
         MiniProfile.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y + 10);
         MiniProfile.TopMost = true;
         MiniProfile.Show();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
示例#8
0
		public void TestPublicMethods ()
		{
			// Public Methods that force Handle creation:
			// - CreateGraphics ()
			// - GetChildAtPoint ()
			// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
			// - PointToClient ()
			// - PointToScreen ()
			// - RectangleToClient ()
			// - RectangleToScreen ()
			// - Select ()
			// - Show (IWin32Window)
			// Notes:
			// - CreateControl does NOT force Handle creation!
			
			Form c = new Form ();

			c.BringToFront ();
			Assert.IsFalse (c.IsHandleCreated, "A1");
			
			c.Contains (new Form ());
			Assert.IsFalse (c.IsHandleCreated, "A2");
			
			c.CreateControl ();
			Assert.IsFalse (c.IsHandleCreated, "A3");
			
			c = new Form ();
			Graphics g = c.CreateGraphics ();
			g.Dispose ();
			Assert.IsTrue (c.IsHandleCreated, "A4");
			c.Dispose ();
			c = new Form ();
			
			c.Dispose ();
			Assert.IsFalse (c.IsHandleCreated, "A5");
			c = new Form ();

			// This is weird, it causes a form to appear that won't go away until you move the mouse over it, 
			// but it doesn't create a handle??
			//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.Dispose ();
			c = new Form ();
			
			c.GetContainerControl ();
			Assert.IsFalse (c.IsHandleCreated, "A11");
			c.Dispose ();
			
			c = new Form ();
			c.GetNextControl (new Control (), true);
			Assert.IsFalse (c.IsHandleCreated, "A12");
			c.GetPreferredSize (Size.Empty);
			Assert.IsFalse (c.IsHandleCreated, "A13");
			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.Dispose ();
			c = new Form ();
			
			c.PointToScreen (new Point (100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A19");
			c.Dispose ();
			
			c = new Form ();
			
			//c.PreProcessControlMessage   ???
			//c.PreProcessMessage          ???
			c.RectangleToClient (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A20");
			c.Dispose ();
			c = new Form ();
			c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
			Assert.IsTrue (c.IsHandleCreated, "A21");
			c.Dispose ();
			c = new Form ();
			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");
			c.Scale (new SizeF (1.5f, 1.5f));
			Assert.IsFalse (c.IsHandleCreated, "A33");
			c.Select ();
			Assert.IsTrue (c.IsHandleCreated, "A34");
			c.Dispose ();
			
			c = new Form ();
			
			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");
			
			// Form
			
			c.Activate ();
			Assert.IsFalse (c.IsHandleCreated, "F1");
			
			c.AddOwnedForm (new Form ());
			Assert.IsFalse (c.IsHandleCreated, "F2");
			
			c.Close ();
			Assert.IsFalse (c.IsHandleCreated, "F3");
			
			c.Hide ();
			Assert.IsFalse (c.IsHandleCreated, "F4");
			
			c.LayoutMdi (MdiLayout.Cascade);
			Assert.IsFalse (c.IsHandleCreated, "F5");

#if !MONO
			c.PerformAutoScale ();
			Assert.IsFalse (c.IsHandleCreated, "F6"); 
#endif
			
			c.PerformLayout ();
			Assert.IsFalse (c.IsHandleCreated, "F7");
			
			c.AddOwnedForm (new Form ());
			c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]);
			Assert.IsFalse (c.IsHandleCreated, "F8");
			
			c.ScrollControlIntoView (null);
			Assert.IsFalse (c.IsHandleCreated, "F9");
			
			c.SetAutoScrollMargin (7, 13);
			Assert.IsFalse (c.IsHandleCreated, "F10");
			
			c.SetDesktopBounds (-1, -1, 144, 169);
			Assert.IsFalse (c.IsHandleCreated, "F11");
			
			c.SetDesktopLocation (7, 13);
			Assert.IsFalse (c.IsHandleCreated, "F12");

			c = new Form ();
			c.Show (null);
			Assert.IsTrue (c.IsHandleCreated, "F13");
			c.Close ();
			c = new Form (); 
			
			//c.ShowDialog ()
			
			c.ToString ();
			Assert.IsFalse (c.IsHandleCreated, "F14");
			
			c.Validate ();
			Assert.IsFalse (c.IsHandleCreated, "F15");

#if !MONO
			c.ValidateChildren ();
			Assert.IsFalse (c.IsHandleCreated, "F16"); 
#endif

			c.Close ();
		}
示例#9
0
        /// <summary>
        /// Position the form on the same monitor the user has put our app!
        /// (by default, forms are open on the primary monitor, but if the user dragged
        /// our form to another monitor the child forms still get created on the main monitor.
        /// This is a small quality of life fix)
        /// </summary>
        /// <param name="f">The form to move</param>
        public void SetUpForm(System.Windows.Forms.Form f)
        {
            Point desktop = this.DesktopLocation;

            f.SetDesktopLocation(desktop.X + 100, desktop.Y + 100);
        }
示例#10
0
		public void SetDesktopLocationTest ()
		{
			Form myform = new Form ();
			myform.ShowInTaskbar = false;
			myform.Visible = true;
			myform.Text = "NewForm";
			myform.Name = "FormTest";
			myform.SetDesktopLocation (10, 10);
			Assert.AreEqual (10, myform.DesktopLocation.X, "#46");
			myform.Dispose ();
		}
示例#11
0
        public static void PositionBottomRightDesktop(Form Target)
        {
            Rectangle desktopDimenions = Screen.PrimaryScreen.WorkingArea;

            Point topLeft = new Point(desktopDimenions.Width - Target.Width - 5, desktopDimenions.Height - Target.Height - 5);

            Target.SetDesktopLocation(topLeft.X, topLeft.Y);
        }
示例#12
-1
		public static void SetFormToRightEdge(Form fm)
		{
			Rectangle monitor = GetCurrentMonitor(fm);

			fm.SetDesktopLocation(monitor.Right - fm.Width, 0);
			fm.Size = new Size(fm.Size.Width, monitor.Bottom - fm.Location.Y);

			LeftSide = false;
		}