FindForm() публичный Метод

public FindForm ( ) : Form
Результат Form
Пример #1
1
 public static CardView FindParentCardView(Control control)
 {
     Control parent = control.Parent;
       while(parent != control.FindForm() && !(parent is CardView))
     parent = parent.Parent;
       return parent as CardView;
 }
Пример #2
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IntPtr hwnd = Window.Handle;

            //graphics.SynchronizeWithVerticalRetrace = false;
            //IsFixedTimeStep = false;
            Forms.Control ctrl = Forms.Control.FromHandle(hwnd);
            form = ctrl.FindForm();
            form.AcceptButton = null;
            form.CancelButton = null;
            savebutton.Click += new EventHandler(delegate
            {
                SaveToTxt("map.txt");
            });
            form.KeyUp       += OnKeyUp;
            loadbutton.Click += new EventHandler(delegate
            {
                LoadFromTxt();
            });
            form.Controls.Add(connectbutton);
            form.Controls.Add(ipadd);
            form.Controls.Add(savebutton);
            form.Controls.Add(loadbutton);
        }
Пример #3
0
        /// <summary>
        /// Erzeugt eine neue Überlagerung.
        /// </summary>
        /// <param name="reference">Dieses Steuerelement dient als Bezugspunkt.</param>
        /// <exception cref="ArgumentNullException">Es wurde kein Bezugspunkt angegeben.</exception>
        public OverlayWindow( Control reference )
        {
            // Validate
            if (reference == null)
                throw new ArgumentNullException( "reference" );

            // Remember
            m_ReferenceForm = reference.FindForm();
            m_Reference = reference;

            // Load designer stuff
            InitializeComponent();

            // Finish
            if (UseLegacyOverlay)
                picOSD.Dock = DockStyle.Fill;
            else
                TransparencyKey = TTXPage.TransparentColor.Color;

            // Attach location changes
            m_ReferenceForm.LocationChanged += AdaptChanges;
            m_ReferenceForm.SizeChanged += AdaptChanges;
            m_Reference.LocationChanged += AdaptChanges;
            m_Reference.SizeChanged += AdaptChanges;

            // Adjust to initial size
            AdaptChanges( m_Reference, EventArgs.Empty );
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p_ctlCurrent"></param>
        /// <param name="p_lviSelected"></param>
        protected override void m_mthSetSelectValueSub(System.Windows.Forms.Control p_ctlCurrent, System.Windows.Forms.ListViewItem p_lviSelected)
        {
            try
            {
                clsEmployee objEmp = (clsEmployee)p_lviSelected.Tag;

                if (objEmp == null)
                {
                    return;
                }

                if (m_blnNeedPwd)
                {
                    if (!m_blnCheckEmployeeSign(p_ctlCurrent.FindForm(), objEmp.m_StrEmployeeID, objEmp.m_StrLastName))
                    {
                        return;
                    }
                }

                p_ctlCurrent.Text = objEmp.m_StrLastName;
                p_ctlCurrent.Tag  = objEmp;
            }
            catch (Exception ex)
            {
            }
        }
Пример #5
0
 public HelpBtn2(Control Src) {
     Control C = new Control();
     C.Parent = (this.form = Src.FindForm());
     C.Capture = true;
     C.Cursor = Cursors.Help;
     C.MouseDown += new MouseEventHandler(C_MouseDown);
 }
Пример #6
0
    public static Image GetImage(Control c_)
    {
      Graphics g = null;
      Image ret = null;
      try
      {
        if (c_ is Form)
          c_.BringToFront();
        else
          c_.FindForm().BringToFront();

        Application.DoEvents();

        g = c_.CreateGraphics();
        ret = new Bitmap(c_.ClientRectangle.Width, c_.ClientRectangle.Height, g);
        Graphics g2 = Graphics.FromImage(ret);
        IntPtr dc1 = g.GetHdc();
        IntPtr dc2 = g2.GetHdc();
        BitBlt(dc2, 0, 0, c_.ClientRectangle.Width, c_.ClientRectangle.Height, dc1, 0, 0, 13369376);
        g.ReleaseHdc(dc1);
        g2.ReleaseHdc(dc2);
      }
      finally
      {
        if (g != null)
          g.Dispose();
      }

      return ret;
    }
Пример #7
0
        /// <summary>
        /// 显示一个定时标签消息框。
        /// </summary>
        /// <param name="owner">控件拥有者。</param>
        /// <param name="parameters">设置参数。</param>
        public static void ShowLabel(this Control owner, MessageLabelParameters parameters)
        {
            if (owner != null && owner.InvokeRequired)
            {
                owner.Invoke(new Action <Control, MessageLabelParameters>(ShowLabel), owner, parameters);
            }
            else
            {
                if (owner == null)
                {
                    new MessageLabelForm(null, parameters).Show();
                    return;
                }
                var waitingTask = owner as IWaitingTask;
                var ownerForm   = waitingTask == null?owner.FindForm() : waitingTask.CallerForm;

                if (ownerForm == null)
                {
                    return;
                }

                if (ownerForm.InvokeRequired)
                {
                    new MessageLabelForm(null, parameters).Show();
                }
                else
                {
                    ownerForm.Activate();
                    new MessageLabelForm(owner, parameters).Show(ownerForm);
                    ownerForm.Activate();
                }
            }
        }
Пример #8
0
        void IDisplayHandler.OnFullscreenModeChange(IWebBrowser browserControl, IBrowser browser, bool fullscreen)
        {
            var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;

            chromiumWebBrowser.InvokeOnUiThreadIfRequired(() =>
            {
                if (fullscreen)
                {
                    parent = chromiumWebBrowser.Parent;

                    parent.Controls.Remove(chromiumWebBrowser);

                    fullScreenForm = new Form();
                    fullScreenForm.FormBorderStyle = FormBorderStyle.None;
                    fullScreenForm.WindowState = FormWindowState.Maximized;

                    fullScreenForm.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.ShowDialog(parent.FindForm());
                }
                else
                {
                    fullScreenForm.Controls.Remove(chromiumWebBrowser);

                    parent.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.Close();
                    fullScreenForm.Dispose();
                    fullScreenForm = null;
                }
            });
        }
Пример #9
0
 public static PlayerStatusView FindParentPlayerStatusView(Control control)
 {
     Control parent = control.Parent;
       while(parent != control.FindForm() && !(parent is PlayerStatusView))
     parent = parent.Parent;
       return parent as PlayerStatusView;
 }
Пример #10
0
 /// <summary>
 /// Shows a dialog box.
 /// If the owner of the dialog is a popup window, then this method uses <see cref="FormUtil.FindTopLevelOwner"/> 
 /// to find the appropriate main window to own the dialog, and after the dialog is closed, sets the focus back 
 /// to the correct control.
 /// </summary>
 public static DialogResult ShowDialog(Control owner, Form dialog)
 {
     Form ownerForm = null;
     if (null != owner)
     {
         ownerForm = owner.FindForm();
     }
     var topLevelOwner = FindTopLevelOwner(owner);
     Control activeControl = null;
     if (null != ownerForm && ownerForm.ContainsFocus)
     {
         activeControl = ownerForm.ActiveControl;
     }
     var dialogResult = dialog.ShowDialog(topLevelOwner);
     if (null != activeControl)
     {
         if (ownerForm != topLevelOwner)
         {
             // Put the focus first on the window which was the owner of the dialog box.
             // Otherwise when the ownerForm is closed, the focus will go to a different application
             topLevelOwner.Focus();
             // Then put the focus on the control which had the focus before the dialog came up
             activeControl.Focus();
         }
     }
     return dialogResult;
 }
Пример #11
0
		public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData) {
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;

			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}

				workingArea = Screen.GetWorkingArea(ownerForm);
			}

			PointF screenLocation = control.PointToScreen(Point.Empty);
			SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2, workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);

			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;

				tipData.SetMaximumSize(maxLayoutSize);
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);

				tipSizeF += new SizeF(HorizontalBorder * 2, VerticalBorder * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}

			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}

			return tipSize;
		}
Пример #12
0
        private void _Find(Control control)
        {
            if (_control != null)
            {
                if (__trace)
                    Trace.WriteLine("ControlFindForm remove ParentChanged event for control {0}", _control.GetType().Name);
                _control.ParentChanged -= Control_ParentChanged;
                _control = null;
            }

            Form form = control.FindForm();
            if (form != null)
            {
                if (__trace)
                    Trace.WriteLine("ControlFindForm found form");
                _result(form);
            }
            else
            {
                while (true)
                {
                    Control parent = control.Parent;
                    if (parent == null)
                    {
                        if (__trace)
                            Trace.WriteLine("ControlFindForm add ParentChanged event for control {0}", control.GetType().Name);
                        control.ParentChanged += Control_ParentChanged;
                        _control = control;
                        break;
                    }
                    control = parent;
                }
            }
        }
Пример #13
0
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="parent"></param>
		public WPopUpFormBase(Control parent)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			m_Parent = parent;
			m_ParentForm = m_Parent.FindForm();
			
			if(Form.ActiveForm != null && Form.ActiveForm.IsMdiContainer){
				m_MdiParent = Form.ActiveForm;

				m_MdiParent.LostFocus += new System.EventHandler(this.ParentLostFocus);
				m_MdiParent.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ParentFormMouseClick);
				m_MdiParent.Move      += new System.EventHandler(this.ParentFormMoved);
			}
						
			m_ParentForm.LostFocus += new System.EventHandler(this.ParentLostFocus);
			m_ParentForm.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ParentFormMouseClick);
			m_ParentForm.Move      += new System.EventHandler(this.ParentFormMoved);

			if(!object.ReferenceEquals(m_Parent.Parent,m_ParentForm)){
				m_Parent.Parent.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ParentFormMouseClick);
			}

        }
Пример #14
0
        public static void RemoveAll(Control control)
        {
            if ((control != null) && (control.Controls.Count > 0))
            {
                Button tempButton = null;
                Form parentForm = control.FindForm();

                if (parentForm != null)
                {
                    // Create a hidden, temporary button
                    tempButton = new Button();
                    tempButton.Visible = false;

                    // Add this temporary button to the parent form
                    parentForm.Controls.Add(tempButton);

                    // Must ensure that temp button is the active one
                    parentForm.ActiveControl = tempButton;
                }

              				// Remove all entries from target
                control.Controls.Clear();

                if (parentForm != null)
                {
                    // Remove the temporary button
                    tempButton.Dispose();
                    parentForm.Controls.Remove(tempButton);
                }
            }
        }
Пример #15
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)));
         }
     }
 }
Пример #16
0
        public static string GetFieldInfo(Control control, string indent = "  ", string newLine = null)
        {
            newLine = newLine ?? Environment.NewLine.ToString();

            var text = "";

            for (var c = control; c != null; c = c.Parent)
            {
                var field = ReverseLookupField(c);
                if (field == null)
                {
                    break;
                }

                text = newLine + indent + field.Name + ":" + c.GetType().Name + text;
            }

            var form = control.FindForm();

            if (form != null)
            {
                text = newLine + indent + form.GetType().Name + text;
            }

            return(text);
        }
Пример #17
0
        public static SnapManager FindMySnapManager(Control me)
        {
            if (!(me is ISnapObstacleHost))
            {
                throw new ArgumentException("must be called with a Control that implements ISnapObstacleHost");
            }

            ISnapManagerHost ismh;

            ismh = me as ISnapManagerHost;

            if (ismh == null)
            {
                ismh = me.FindForm() as ISnapManagerHost;
            }

            SnapManager sm;
            if (ismh != null)
            {
                sm = ismh.SnapManager;
            }
            else
            {
                sm = null;
            }

            return sm;
        }
Пример #18
0
        public static void Remove(Control.ControlCollection coll, Control item)
        {
            if ((coll != null) && (item != null))
            {
                Button tempButton = null;
                Form parentForm = item.FindForm();

                if (parentForm != null)
                {
                    // Create a hidden, temporary button
                    tempButton = new Button();
                    tempButton.Visible = false;

                    // Add this temporary button to the parent form
                    parentForm.Controls.Add(tempButton);

                    // Must ensure that temp button is the active one
                    parentForm.ActiveControl = tempButton;
                }

                // Remove our target control
                coll.Remove(item);

                if (parentForm != null)
                {
                    // Remove the temporary button
                    tempButton.Dispose();
                    parentForm.Controls.Remove(tempButton);
                }
            }
        }
Пример #19
0
		protected bool BeginDrag(Control c)
		{
			// Avoid re-entrance;
			if (m_dragControl != null)
				return false;

			m_startMousePosition = Control.MousePosition;

			if (!User32.DragDetect(c.Handle, StartMousePosition))
				return false;

			m_dragControl = c;
			c.FindForm().Capture = true;
			AssignHandle(c.FindForm().Handle);
			Application.AddMessageFilter(this);
			return true;
		}
Пример #20
0
		public static Size GetTipSize(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}
				
				workingArea = Screen.GetWorkingArea(ownerForm);
			}
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			SizeF maxLayoutSize = new SizeF(workingArea.Right /*- screenLocation.X*/ - HorizontalBorder * 2,
			                                workingArea.Bottom /*- screenLocation.Y*/ - VerticalBorder * 2);
			
			float global_max_x = workingArea.Right - HorizontalBorder * 2;
			
			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				/*graphics.TextRenderingHint =
				TextRenderingHint.AntiAliasGridFit;*/
				tipData.GlobalMaxX = global_max_x;
				tipData.SetMaximumSize(maxLayoutSize);
				//if (tipData.LeftOffset > 0) 
				//	control.Left = control.Left - tipData.LeftOffset;
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);
				
				tipSizeF += new SizeF(HorizontalBorder * 2,
				                      VerticalBorder   * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}
			if (control is ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow)
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = (control as ICSharpCode.TextEditor.Gui.InsightWindow.PABCNETInsightWindow).GetCusorCoord();
				if (pt.X + tipSize.Width > rect.Width)
				{
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
				}
			}
			else
			{
				Rectangle rect = Rectangle.Ceiling(workingArea);
				Point pt = control.Location;
				if (pt.X + tipSize.Width > rect.Width)
				{
					control.Location = new Point(rect.Width-tipSize.Width,pt.Y);
				}
			}
			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}
			
			return tipSize;
		}
Пример #21
0
		static Rectangle GetWorkingArea(Control control)
		{
			Form ownerForm = control.FindForm();
			if (ownerForm.Owner != null) {
				ownerForm = ownerForm.Owner;
			}
			
			return Screen.GetWorkingArea(ownerForm);
		}
Пример #22
0
        public TwainHelper(Control ctr)
        {
            tw = new Twain();
            this.ctr = ctr;
            frm = ctr.FindForm();

            ctr.BackgroundImageLayout = ImageLayout.Stretch;
            tw.Init(ctr.Handle);
        }
Пример #23
0
        public static String FieldName(Control ctrl)
        {
            if (ctrl == null || !ctrl.IsHandleCreated)
            {
                return("null");
            }
            var field = ReverseLookupField(ctrl);

            return(field?.Name ?? ctrl.FindForm()?.Name ?? "<?>");
        }
Пример #24
0
        /// <summary>
        /// 在新线程启动等待窗体。并在 <see cref="System.IDisposable"/> 后关闭等待窗体。
        /// </summary>
        /// <param name="owner">控件。</param>
        /// <param name="text">等待窗体的内容。</param>
        /// <param name="centerScreen">表示是否居中于桌面。</param>
        public static Form BeginRun(this Control owner, string text, bool centerScreen = false)
        {
            WaitingForm fw = null;
            Thread      t  = null;

            t = new Thread(() =>
            {
                var ownerForm = owner.FindForm();
                fw            = new WaitingForm(false, ownerForm);

                fw.OwnerThread = t;
                if (centerScreen)
                {
                    fw.StartPosition = FormStartPosition.CenterScreen;
                }
                else
                {
                    int x            = owner.Location.X + (owner.Width - fw.Width) / 2;
                    int y            = owner.Location.Y + (owner.Height - fw.Height) / 2 - SystemInformation.CaptionHeight;
                    fw.Location      = new Point(x, y);
                    fw.StartPosition = FormStartPosition.Manual;
                }
                fw.Text          = text;
                EventHandler act = (ss, ee) =>
                {
                    if (fw.IsHandleCreated)
                    {
                        fw.BeginInvoke(new Action(fw.Activate));
                    }
                };
                if (ownerForm != null)
                {
                    ownerForm.Activated += act;
                }
                try
                {
                    fw.ShowDialog();
                }
                catch (ThreadAbortException) { }
                catch (Exception) { }

                if (ownerForm != null)
                {
                    ownerForm.Activated -= act;
                }
            });

            t.Start();
            while (fw == null || !fw.IsShown)
            {
                Application.DoEvents();
            }

            return(fw);
        }
Пример #25
0
        public bool Ignore( Control owner )
        {
            Form f = owner.FindForm();

            if( f == null )
            {
                return false;
            }

            return f.WindowState == FormWindowState.Maximized;
        }
Пример #26
0
 public void ShowByControl(Control ctl, Point screenpos)
 {
     if(ctl==null)
         throw new ArgumentNullException("ctl");
     this.Location=screenpos;
     //filters
     Application.AddMessageFilter(_mousefilter);
     Form mainfrm=ctl.FindForm();
     if(mainfrm!=null)
         _activationfilter.AssignHandle(mainfrm);
     base.Show();
 }
Пример #27
0
		public static Size DrawTip(Control control, Graphics graphics, TipSection tipData)
		{
			Size tipSize = Size.Empty;
			SizeF tipSizeF = SizeF.Empty;
			
			PointF screenLocation = control.PointToScreen(Point.Empty);
			
			if (workingArea == RectangleF.Empty) {
				Form ownerForm = control.FindForm();
				if (ownerForm.Owner != null) {
					ownerForm = ownerForm.Owner;
				}
				
				workingArea = Screen.GetWorkingArea(ownerForm);
			}
	
			SizeF maxLayoutSize = new SizeF(workingArea.Right - screenLocation.X - HorizontalBorder * 2,
			                                workingArea.Bottom - screenLocation.Y - VerticalBorder * 2);
			
			if (maxLayoutSize.Width > 0 && maxLayoutSize.Height > 0) {
				//graphics.TextRenderingHint =
				//TextRenderingHint.AntiAliasGridFit;
				
				tipData.SetMaximumSize(maxLayoutSize);
				tipSizeF = tipData.GetRequiredSize();
				tipData.SetAllocatedSize(tipSizeF);
				
				tipSizeF += new SizeF(HorizontalBorder * 2,
				                      VerticalBorder   * 2);
				tipSize = Size.Ceiling(tipSizeF);
			}
			
			if (control.ClientSize != tipSize) {
				control.ClientSize = tipSize;
			}
			
			if (tipSize != Size.Empty) {
				Rectangle borderRectangle = new Rectangle
				(Point.Empty, tipSize - new Size(1, 1));
				
				RectangleF displayRectangle = new RectangleF
				(HorizontalBorder, VerticalBorder,
				 tipSizeF.Width - HorizontalBorder * 2,
				 tipSizeF.Height - VerticalBorder * 2);
				
				// DrawRectangle draws from Left to Left + Width. A bug? :-/
				graphics.DrawRectangle(SystemPens.WindowFrame,
				                       borderRectangle);
				tipData.Draw(new PointF(HorizontalBorder, VerticalBorder));
			}
			return tipSize;
		}
Пример #28
0
        void _control_DragDrop(object sender, DragEventArgs e)
        {
            var form = _control.FindForm();

            form.Activate();

            var dropData = new FilesDropData(e.Data);

            if (dropData.HasFiles)
            {
                OnDragDrop(new FilesDragEventArgs(dropData, new Point(e.X, e.Y), e.AllowedEffect, e.KeyState));
            }
        }
Пример #29
0
        /// <summary>
        /// 启动多线程等待。action 委托是在多线程中调用。并执行后续操作。
        /// </summary>
        /// <typeparam name="TResult">返回值数据类型。</typeparam>
        /// <param name="owner">控件。</param>
        /// <param name="text">等待窗体的内容。</param>
        /// <param name="func">在多线程中运行的委托,这个委托带有一个返回值。</param>
        /// <param name="taksControl">等待窗体。</param>
        private static TResult Run <TResult>(this Control owner, string text, Func <Form, TResult> func, IWaitingTask taksControl)
        {
            TResult result = default(TResult);
            Thread  t      = new Thread((p) =>
            {
                var old = Control.CheckForIllegalCrossThreadCalls;
                Control.CheckForIllegalCrossThreadCalls = false;
                var waitingForm = p as IWaitingTask;
                try
                {
                    while (!waitingForm.IsShown)
                    {
                        Application.DoEvents();
                    }
                    result = func(p as Form);

                    waitingForm.Dispose();
                }
                catch (ThreadAbortException) { }
                Control.CheckForIllegalCrossThreadCalls = old;
            });

            t.IsBackground          = true;
            taksControl.OwnerThread = t;
            taksControl.Text        = text;
            var ownerForm = owner.FindForm();

            ownerForm.Activate();
            ownerForm.Focus();
            t.Start(taksControl);
            try
            {
                taksControl.ShowForm(ownerForm);
            }
            catch (InvalidOperationException)
            {
                if (!taksControl.IsDisposed)
                {
                    taksControl.Dispose();
                }
            }
            catch (Exception ex)
            {
                ownerForm.ShowError(ex.Message);
            }
            finally
            {
                ownerForm.Activate();
            }
            return(result);
        }
Пример #30
0
        internal MessageLabelForm(Control owner, MessageLabelParameters parameters)
        {
            this.InitializeComponent(parameters);

            var size = this.RectangleToScreen(this.DisplayRectangle).Size;

            this.AutoSize        = false;
            lbl_Content.AutoSize = false;
            this.Size            = size;
            if (parameters.Point.HasValue)
            {
                this.Location = parameters.Point.Value;
            }
            else
            {
                if (owner == null)
                {
                    owner = System.Windows.Forms.Form.ActiveForm;
                }
                if (owner == null)
                {
                    this.StartPosition = FormStartPosition.CenterScreen;
                }
                else
                {
                    Form ownerForm = owner.FindForm();
                    if (ownerForm.ParentForm != null)
                    {
                        ownerForm = ownerForm.ParentForm;
                    }
                    if (ownerForm.MdiParent != null)
                    {
                        ownerForm = ownerForm.MdiParent;
                    }

                    this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

                    if (parameters.IsAlignmentScreen)
                    {
                        this.Location = this.GetPoint(Screen.GetWorkingArea(ownerForm), parameters.Alignment);
                    }
                    else
                    {
                        this.Location = this.GetPoint(ownerForm.RectangleToScreen(ownerForm.ClientRectangle), parameters.Alignment);
                    }
                }
            }
            this._closeEnd       = parameters.CloseMillisecond;
            this._timer.Interval = 100;
            this._timer.Tick    += new EventHandler(timer_Tick);
        }
Пример #31
0
        protected override void LoadContent()
        {
            graphics.ApplyChanges();

            control = Form.FromHandle(this.Window.Handle);
            gWindow = control.FindForm();
            gWindow.FormBorderStyle = FormBorderStyle.None;
            gWindow.TopMost = true;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            User32.SetWindowPos((uint)this.Window.Handle, -1, 0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight, 0);
            ModelDataBase.Load(Content);
            ModelDataBase.LoadIntoRenderer(0);
        }
Пример #32
0
 public void Show(string text, Control control)
 {
     if (control == null) throw new ArgumentNullException("control");
     this.tooltipText = text;
     this.CalcFinalSizes();
     this.SetLabel();
     var point = control.FindForm().PointToScreen(control.Location);
     int x = point.X - offsetX;
     int y = point.Y - this.Height;
     this.Location = new Point(x, y);
     this.Show(control);
     control.Focus();
     control.LostFocus += new EventHandler(control_LostFocus);
 }
Пример #33
0
        static public bool TrackPopupMenu(Menu menu, Point pnt)
        {
            if (menu.MenuItems.Count <= 0)              // No submenus to track
            {
                return(true);
            }

            MenuTracker tracker = menu.tracker;

            tracker.active       = true;
            tracker.popup_active = true;

            // Set GrabControl
            Control src_ctrl = (tracker.TopMenu as ContextMenu).SourceControl;

            tracker.GrabControl = src_ctrl.FindForm();
            if (tracker.GrabControl == null)
            {
                tracker.GrabControl = src_ctrl.FindRootParent();
            }
            //tracker.GrabControl.ActiveTracker = tracker;


            menu.Wnd          = new PopUpWindow(tracker.GrabControl, menu);
            menu.Wnd.Location = menu.Wnd.PointToClient(pnt);
            //((PopUpWindow)menu.Wnd).ShowWindow ();

            bool no_quit = true;

            //Object queue_id = XplatUI.StartLoop(Thread.CurrentThread);



            if (tracker.GrabControl.IsDisposed)
            {
                return(true);
            }

            //if (!no_quit)
            //	XplatUI.PostQuitMessage(0);

            if (menu.Wnd != null)
            {
                menu.Wnd.Dispose();
                menu.Wnd = null;
            }

            return(true);
        }
Пример #34
0
        public static Control FindParent(Control child)
        {
            Control parent = null;
            parent = child.FindForm();

            if (parent == null)
            {
                parent = child;
                while (parent != null && !(parent is UserControl))
                {
                    parent = parent.Parent;
                }
            }

            return parent;
        }
 public static void Bind(HelpProvider localHelpProvider, Control control)
 {
     IHelpProviderContext context = control.FindForm() as IHelpProviderContext;
     if (context != null)
     {
         if (localHelpProvider.GetShowHelp(control))
         {
             string helpString = localHelpProvider.GetHelpString(control);
             if (helpString != null)
             {
                 context.HelpProvider.SetShowHelp(control, true);
                 context.HelpProvider.SetHelpString(control, helpString);
             }
         }
     }
 }
Пример #36
0
        //设置添加注释对话框的位置
        private Point setNoteFormLocation(System.Windows.Forms.Control c)
        {
            Point location = new Point();
            int   x1       = c.Location.X;
            int   y1       = c.Location.Y;
            int   x2       = c.FindForm().Controls.Find("gboxMCCS", true)[0].Location.X;
            int   y2       = c.FindForm().Controls.Find("gboxMCCS", true)[0].Location.Y;
            int   x3       = c.FindForm().Controls.Find("gboxMCL", true)[0].Location.X;
            int   y3       = c.FindForm().Controls.Find("gboxMCL", true)[0].Location.Y;
            int   x4       = c.FindForm().Location.X;
            int   y4       = c.FindForm().Location.Y;
            int   x5       = c.FindForm().Controls.Find("panel1", true)[0].Location.X;
            int   y5       = c.FindForm().Controls.Find("panel1", true)[0].Location.Y;

            location.X = x1 + x2 + x3 + x4 + y5;
            location.Y = y1 + y2 + y3 + y4 + y5 + 55;
            return(location);
        }
Пример #37
0
        /// <summary>
        /// Used to make the browser full screen
        /// </summary>
        public void OnFullscreenModeChange(IWebBrowser browserControl, IBrowser browser, bool fullscreen)
        {
            //Setting a new ChromiumWebBrowser
            var chromiumBrowser = (ChromiumWebBrowser)browserControl;

            //Invoke on UI thread
            chromiumBrowser.InvokeOnUiThreadIfRequired(() =>
            {
                //Checks if we are going into fullscreen
                if (fullscreen)
                {
                    //Setting the parent of the ChromiumWebBrowser
                    Parent = chromiumBrowser.Parent;

                    //Remove the tab browser from the BrowserTab
                    Parent.Controls.Remove(chromiumBrowser);

                    //Initialize fullScreenForm
                    fullScreenForm = new Form();

                    //Set Windows state and FormBorderStyle to be full screen.
                    fullScreenForm.WindowState     = FormWindowState.Maximized;
                    fullScreenForm.FormBorderStyle = FormBorderStyle.None;

                    //Add the ChromiumWebBrowser to the fullscreenform.
                    fullScreenForm.Controls.Add(chromiumBrowser);

                    //Show the Dialog of the fullscreenform.
                    fullScreenForm.ShowDialog(Parent.FindForm());
                }
                else
                {
                    //Remove the ChromiumWebBrowser from the fullscreenform
                    fullScreenForm.Controls.Remove(chromiumBrowser);

                    //Add the ChromiumWebBrowser back to the parent.
                    Parent.Controls.Add(chromiumBrowser);

                    //Closes and dispose of FullScreenForm
                    fullScreenForm.Close();
                    fullScreenForm.Dispose();
                    fullScreenForm = null;
                }
            });
        }
Пример #38
0
		// ------------------------------------------------------------------

		/// <summary>
		/// Checks whether a control or its parent is in design mode.
		/// </summary>
		/// <param name="c">The control to check.</param>
		/// <returns>
		/// Returns TRUE if in design mode, FALSE otherwise.
		/// </returns>
		public static bool IsDesignMode(
			Control c )
		{
			if ( c == null )
			{
				return
					ZetaLib.Windows.
					LibraryConfiguration.IsDesignMode;
			}
			else
			{
				if ( (c is FormBase) && (c as FormBase).IsDesignMode )
				{
					return true;
				}
				else
				{
					Form f = c.FindForm();

					if ( (f is FormBase) && (f as FormBase).IsDesignMode )
					{
						return true;
					}
					else
					{
						while ( c != null )
						{
							if ( c.Site != null && c.Site.DesignMode )
							{
								return true;
							}
							else
							{
								c = c.Parent;
							}
						}

						return
							ZetaLib.Windows.
							LibraryConfiguration.IsDesignMode;
					}
				}
			}
		}
Пример #39
0
 public Form getForm()
 {
     if (_owner != null)
     {
         if (_owner.GetType() == typeof(ToolStripDropDown))
         {
             ToolStripDropDown own = (ToolStripDropDown)_owner;
             return(own.getForm());
         }
         else
         {
             return(_owner.FindForm());
         }
     }
     else
     {
         return(null);
     }
 }
Пример #40
0
 /// <summary>
 /// 显示一个输入框。
 /// </summary>
 /// <param name="owner">控件拥有者。</param>
 /// <param name="parameters">输入框参数。</param>
 /// <returns>返回输入框的值。</returns>
 public static InputBoxResult InputBox(this Control owner, InputBoxParameters parameters)
 {
     if (owner != null && owner.InvokeRequired)
     {
         return((InputBoxResult)owner.Invoke(new Func <Control, InputBoxParameters, InputBoxResult>(InputBox), owner, parameters));
     }
     else
     {
         var form = new InputBoxForm(owner, parameters);
         if (owner == null)
         {
             return(new InputBoxResult(parameters.Editors, form));
         }
         var ownerForm = owner.FindForm();
         ownerForm.Activate();
         var r = new InputBoxResult(parameters.Editors, form);
         ownerForm.Activate();
         return(r);
     }
 }
Пример #41
0
        public ControlWindow(Control control)
        {
            this.control = control;
            input = new InputHandler(control);

            windowedState = new WindowStateBuffer();

            parentForm = control.FindForm();

            if (parentForm == null) throw new ShouldNeverHappenException("A given control somehow has no parent form. (Poor orphan control T_T)");

            parentForm.Resize += OnResize;
            parentForm.GotFocus += OnGotFocus;
            parentForm.LostFocus += OnLostFocus;
            parentForm.FormClosed += OnFormClosed;
            parentForm.Deactivate += OnDeactivate;

            SwapChainWidth = control.ClientSize.Width;
            SwapChainHeight = control.ClientSize.Height;
        }
Пример #42
0
        /// <summary>
        /// 显示一个消息框。
        /// </summary>
        /// <param name="owner">控件拥有者。</param>
        /// <param name="parameters">设置参数。</param>
        /// <returns>返回窗体的操作结果。</returns>
        public static DialogResult ShowMsg(this Control owner, MessageBoxParameters parameters)
        {
            if (owner == null)
            {
                owner = Form.ActiveForm;
            }
            if (owner != null && owner.InvokeRequired)
            {
                return((DialogResult)owner.Invoke(new Func <Control, MessageBoxParameters, DialogResult>(ShowMsg), owner, parameters));
            }
            else
            {
                if (ShowingMsg != null)
                {
                    var e = new ShowingMsgEventArgs(owner, parameters);
                    ShowingMsg(owner, e);
                    if (e.Result != DialogResult.OK)
                    {
                        return(e.Result);
                    }
                }
                if (owner == null)
                {
                    var f = new MessageBoxForm(owner, parameters);
                    var r = f.ShowDialog();
                    parameters.CheckedResult = f.CheckedResult;
                    return(r);
                }
                else
                {
                    var ownerForm = owner.FindForm();

                    ownerForm.Activate();
                    var f = new MessageBoxForm(owner, parameters);
                    var r = f.ShowDialog(owner);
                    ownerForm.Activate();
                    parameters.CheckedResult = f.CheckedResult;
                    return(r);
                }
            }
        }
Пример #43
0
        internal static bool IsOffScreen(Rect bounds, SWF.Control referenceControl, bool scrollable)
        {
            Rect screen;

            if (scrollable)
            {
                screen = Helper.GetControlScreenBounds(referenceControl.Bounds, referenceControl);
            }
            else
            {
                screen = Helper.RectangleToRect(SWF.Screen.GetWorkingArea(referenceControl));
            }

            IRawElementProviderFragment formProvider = null;

            if ((formProvider = ProviderFactory.FindProvider(referenceControl.FindForm())) != null)
            {
                return(!formProvider.BoundingRectangle.IntersectsWith(bounds) || !bounds.IntersectsWith(screen));
            }

            return(!bounds.IntersectsWith(screen));
        }
Пример #44
0
        private void ShowTooltip(Control control)
        {
            last_control = control;

            // Whatever we're displaying right now, we don't want it anymore
            tooltip_window.Visible = false;
            timer.Stop();
            state = TipState.Initial;

            if (!is_active)
            {
                return;
            }

            // ShowAlways controls whether the controls in non-active forms
            // can display its tooltips, even if they are not current active control.
            if (!show_always && control.FindForm() != Form.ActiveForm)
            {
                return;
            }

            string text = (string)tooltip_strings[control];

            if (text != null && text.Length > 0)
            {
                if (active_control == null)
                {
                    timer.Interval = Math.Max(initial_delay, 1);
                }
                else
                {
                    timer.Interval = Math.Max(re_show_delay, 1);
                }

                active_control = control;
                timer.Start();
            }
        }
Пример #45
0
 public static ISectorView FindParentSectorView(Control control)
 {
     Control parent = control.Parent;
       while(parent != control.FindForm() && !(parent is ISectorView))
     parent = parent.Parent;
       return parent as ISectorView;
 }
Пример #46
0
        /// <summary>
        /// 启动多线程等待。action 委托是在多线程中调用。并执行后续操作。
        /// </summary>
        /// <typeparam name="TResult">返回值数据类型。</typeparam>
        /// <param name="owner">控件。</param>
        /// <param name="text">等待窗体的内容。</param>
        /// <param name="func">在多线程中运行的委托,这个委托带有一个返回值。</param>
        public static TResult RunTask <TResult>(this Control owner, string text, Func <Form, TResult> func)
        {
            var waitTask = owner as IWaitingTask;

            return(Run(owner, text, func, new WaitingControl(waitTask == null ? owner.FindForm() : waitTask.CallerForm)));
        }
Пример #47
0
 /// <summary>
 /// 启动多线程等待。action 委托是在多线程中调用。并执行后续操作(Wait是可以强制中断的任务)。
 /// </summary>
 /// <typeparam name="TResult">返回值数据类型。</typeparam>
 /// <param name="owner">控件。</param>
 /// <param name="text">等待窗体的内容。</param>
 /// <param name="func">在多线程中运行的委托,这个委托带有一个返回值。</param>
 public static TResult RunWait <TResult>(this Control owner, string text, Func <Form, TResult> func)
 {
     return(Run(owner, text, func, new WaitingForm(true, owner.FindForm())));
 }
Пример #48
0
        private void ExpandPanel()
        {
            _updateState = true;

            Point pt = PointToScreen(Location);

            pt.Offset(-2, -2);

            if (Width < MinWidth)
            {
                pt.Offset(Width - MinWidth, 0);
            }

            _parent = Parent;

            Parent.Controls.Remove(this);

            AutoScroll  = true;
            BorderStyle = BorderStyle.Fixed3D;

            Rectangle screen = Screen.FromPoint(pt).WorkingArea;
            var       form   = new Form
            {
                FormBorderStyle = FormBorderStyle.None,
                Location        = pt,
                StartPosition   = FormStartPosition.Manual,
                ShowInTaskbar   = false,
                Size            = new Size(Math.Min(screen.Width, Math.Max(MinWidth, Width)),
                                           Math.Min(Math.Max(TotalHeight + 5, Height), screen.Height))
            };


            if (!screen.Contains(form.Bounds))
            {
                int x = form.Right > screen.Right
                                                        ? screen.Right - form.Width
                                                        : (form.Left < screen.Left ? screen.Left : form.Left);
                int y = form.Bottom > screen.Bottom
                                                        ? screen.Bottom - form.Height
                                                        : (form.Top < screen.Top ? screen.Top : form.Top);

                form.Location = new Point(x, y);
            }

            form.Controls.Add(this);

            if (VerticalScroll.Visible)
            {
                if (form.Left > SystemInformation.VerticalScrollBarWidth)
                {
                    form.Left -= SystemInformation.VerticalScrollBarWidth;
                }

                form.Width += SystemInformation.VerticalScrollBarWidth;
            }

            form.Show(_parent.FindForm());
            form.Deactivate += form_Deactivate;
            form.FormClosed += form_FormClosed;

            _droppedDown = true;
            _updateState = false;
        }
Пример #49
0
 public static object CallControlFindForm(Control c, object[] obj)
 {
     return(c.FindForm());
 }
Пример #50
0
        static public bool TrackPopupMenu(Menu menu, Point_ pnt)
        {
            if (menu.MenuItems.Count <= 0)              // No submenus to track
            {
                return(true);
            }

            MenuTracker tracker = menu.tracker;

            tracker.active       = true;
            tracker.popup_active = true;

            // Set GrabControl
            Control src_ctrl = (tracker.TopMenu as ContextMenu).SourceControl;

            tracker.GrabControl = src_ctrl.FindForm();
            if (tracker.GrabControl == null)
            {
                tracker.GrabControl = src_ctrl.FindRootParent();
            }
            tracker.GrabControl.ActiveTracker = tracker;

            menu.Wnd          = new PopUpWindow(tracker.GrabControl, menu);
            menu.Wnd.Location = menu.Wnd.PointToClient(pnt);
            ((PopUpWindow)menu.Wnd).ShowWindow();

            bool no_quit = true;

            Object queue_id = XplatUI.StartLoop(Thread.CurrentThread);

            while ((menu.Wnd != null) && menu.Wnd.Visible && no_quit)
            {
                MSG msg = new MSG();
                no_quit = XplatUI.GetMessage(queue_id, ref msg, IntPtr.Zero, 0, 0);

                switch ((Msg)msg.message)
                {
                case Msg.WM_KEYDOWN:
                case Msg.WM_SYSKEYDOWN:
                case Msg.WM_CHAR:
                case Msg.WM_SYSCHAR:
                case Msg.WM_KEYUP:
                case Msg.WM_SYSKEYUP:
                    Control c = Control.FromHandle(msg.hwnd);
                    if (c != null)
                    {
                        Message m = Message.Create(msg.hwnd, (int)msg.message, msg.wParam, msg.lParam);
                        c.PreProcessControlMessageInternal(ref m);
                    }
                    break;

                default:
                    XplatUI.TranslateMessage(ref msg);
                    XplatUI.DispatchMessage(ref msg);
                    break;
                }
            }

            if (tracker.GrabControl.IsDisposed)
            {
                return(true);
            }

            if (!no_quit)
            {
                XplatUI.PostQuitMessage(0);
            }

            if (menu.Wnd != null)
            {
                menu.Wnd.Dispose();
                menu.Wnd = null;
            }

            return(true);
        }
Пример #51
0
 public override void Exit()
 {
     System.Windows.Forms.Control c = parentBrwoser as System.Windows.Forms.Control;
     AppContext.MainWindow.Switch(c.FindForm().Name);
 }
Пример #52
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// If the annotations window is gaining focus, then we don't want the draft view's
		/// range selections to be hidden.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override VwSelectionState GetNonFocusedSelectionState(Control windowGainingFocus)
		{
			if (windowGainingFocus != null)
			{
				Form frm = windowGainingFocus.FindForm();
				if (frm is NotesMainWnd)
					return VwSelectionState.vssOutOfFocus;
			}

			return base.GetNonFocusedSelectionState(windowGainingFocus);
		}
Пример #53
0
 public override bool CheckUserAccessPermission(System.Windows.Forms.Control control)
 {
     Model.Common.User currentUser = Setting.User.ThisProgram.GetCurrentUser <Model.Common.User>();
     if (currentUser == null)
     {
         return(true);
     }
     if (IsMembershipInAdministartorRole(currentUser))
     {
         return(true);
     }
     if (!(control.TopLevelControl is System.Windows.Forms.Form))
     {
         return(true);
     }
     System.Windows.Forms.Form form = (control is System.Windows.Forms.Form) ? null : control.FindForm();
     if (form is View.Main)
     {
         return(true);
     }
     if (control is View.Login)
     {
         return(true);
     }
     if (control is View.Main)
     {
         return(true);
     }
     //اینها اگر فالس باشد فقط ادمین می تواند به آن دسترسی داشته باشد
     //if (control is View.DossierDocumentsManage2)
     //    return true;
     //if (control is View.UserManageForms.ChangePassword)
     //    return true;
     //if (control is Njit.Program.Forms.PopupForm)
     //    return true;
     //if (control is View.UserManageForms.AddUser)
     //    return true;
     //if (control is View.UserManageForms.UserList)
     //    return true;
     //if (control is View.UserManageForms.UserRoleAddEdit)
     //    return true;
     //if (control is View.UserManageForms.UserRoleList)
     //    return true;
     //if (control is View.UserManageForms.SetPermission)
     //    return true;
     //if (control is View.UserManageForms.UserLog)
     //    return true;
     if (form != null && control is System.Windows.Forms.Button)
     {
         if (form.CancelButton == (control as System.Windows.Forms.Button))
         {
             return(true);
         }
     }
     return(this.CheckUserAccessPermission(currentUser, (control as Njit.Common.IAccessPermission).GetPath(), form != null ? form.Name : null));
 }
Пример #54
0
        /// <summary>
        /// Retrieve the control's text value in the loaded language file.
        /// </summary>
        /// <param name="control">Control to set</param>
        /// <returns>value of control's text in language file</returns>
        /// <history>
        /// [Curtis_Beard]		11/02/2006	Created
        /// </history>
        public static string GetControlText(Control control)
        {
            if (__RootNode != null)
             {
            string formName = control.FindForm().Name;
            XmlNode node = __RootNode.SelectSingleNode("screen[@name='" + formName + "']");
            XmlNode controlNode;

            if (node != null)
            {
               //node found, find control
               controlNode = node.SelectSingleNode("control[@name='" + control.Name + "']");

               if (controlNode != null)
               {
                  //found control node

                  //text
                  if (controlNode.Attributes["value"] != null)
                     return controlNode.Attributes["value"].Value;
               }
            }
             }

             return string.Empty;
        }
Пример #55
0
        /// <summary>
        /// Sets the given control's text property.
        /// </summary>
        /// <param name="control">Control to set</param>
        /// <param name="tip">ToolTip control</param>
        /// <history>
        /// [Curtis_Beard]		07/31/2006	Created
        /// </history>
        public static void SetControlText(Control control, ToolTip tip)
        {
            if (__RootNode != null)
             {
            string formName = control.FindForm().Name;
            XmlNode node = __RootNode.SelectSingleNode("screen[@name='" + formName + "']");
            XmlNode controlNode;

            if (node != null)
            {
               //node found, find control
               controlNode = node.SelectSingleNode("control[@name='" + control.Name + "']");

               if (controlNode != null)
               {
                  //found control node

                  //text
                  if (controlNode.Attributes["value"] != null)
                     control.Text = controlNode.Attributes["value"].Value;

                  //tooltip
                  if (tip != null && controlNode.Attributes["tooltip"] != null)
                     tip.SetToolTip(control, controlNode.Attributes["tooltip"].Value);
               }
            }
             }
        }
Пример #56
-1
 private void con_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         int offx             = e.X - p.X;
         int offy             = e.Y - p.Y;
         con.FindForm().Left += offx;
         con.FindForm().Top  += offy;
     }
 }