Пример #1
0
        /// <summary>
        /// Closes the form by click the 'x' in the top right hand corner of the form
        /// </summary>
        public void Close()
        {
            if (NM.IsWindow(Identity.Handle))
            {
                if (NM.IsWindowVisible(Identity.Handle))
                {
                    if (NM.IsIconic(Identity.Handle))
                    {
                        throw new Exception("Can not close the window as it is minimised");
                    }

                    GUI.m_APE.AddFirstMessageGetTitleBarItemRectangle(Identity.Handle, NM.TitleBarStateElement.Close);
                    GUI.m_APE.SendMessages(EventSet.APE);
                    GUI.m_APE.WaitForMessages(EventSet.APE);
                    //Get the value(s) returned MUST be done straight after the WaitForMessages call
                    NM.StateSystem State  = (NM.StateSystem)GUI.m_APE.GetValueFromMessage();
                    int            Top    = GUI.m_APE.GetValueFromMessage();
                    int            Left   = GUI.m_APE.GetValueFromMessage();
                    int            Bottom = GUI.m_APE.GetValueFromMessage();
                    int            Right  = GUI.m_APE.GetValueFromMessage();

                    // Check the close button is actually displayed
                    if (State != NM.StateSystem.STATE_SYSTEM_NORMAL && State != NM.StateSystem.STATE_SYSTEM_PRESSED)
                    {
                        throw new Exception("Can not close the window as the close button is in state '" + State.ToString() + "'");
                    }

                    NM.tagRect WindowRect;
                    NM.GetWindowRect(Identity.Handle, out WindowRect);

                    int X = Left + ((Right - Left) / 2) - WindowRect.left;
                    int Y = Top + ((Bottom - Top) / 2) - WindowRect.top;

                    Input.Block(Identity.ParentHandle, Identity.Handle);
                    try
                    {
                        GUI.Log("Close the " + Identity.Description, LogItemType.Action);
                        base.SingleClickInternal(X, Y, MouseButton.Left, MouseKeyModifier.None);

                        //Wait for the window to disappear
                        base.WaitForControlToNotBeVisible();
                    }
                    finally
                    {
                        Input.Unblock();
                    }
                }
            }
        }
Пример #2
0
        public static void ClickCommon(IntPtr Parent, IntPtr Handle, int X, int Y)
        {
            if (!NM.IsWindowVisible(Handle))
            {
                throw new Exception("Window is not visible");
            }

            if (!NM.IsWindowEnabled(Handle))
            {
                throw new Exception("Window is not enabled");
            }

            IntPtr ActualParent;

            if (Parent == IntPtr.Zero)
            {
                ActualParent = Handle;
            }
            else
            {
                ActualParent = Parent;
            }

            if (NM.IsIconic(ActualParent))
            {
                throw new Exception("Window is minimised");
            }

            if (!ActiveWindow(ActualParent))
            {
                SetFocus(Parent, Handle);
            }
            else
            {
                NM.BringWindowToTop(ActualParent);
            }

            NM.tagPoint thePoint      = MouseMove(Handle, X, Y);
            IntPtr      WindowAtPoint = NM.WindowFromPoint(thePoint);

            if (WindowAtPoint != Handle)
            {
                throw new Exception("Window is obscured");
            }
        }
Пример #3
0
 /// <summary>
 /// Get the forms window state
 /// </summary>
 /// <returns>The window state</returns>
 private string FormWindowState()
 {
     if (NM.IsWindow(Identity.Handle))
     {
         if (NM.IsWindowVisible(Identity.Handle))
         {
             if (Identity.TechnologyType == "Windows Forms (WinForms)")
             {
                 // Get the windows current state
                 GUI.m_APE.AddFirstMessageFindByHandle(DataStores.Store0, Identity.ParentHandle, Identity.Handle);
                 GUI.m_APE.AddQueryMessageReflect(DataStores.Store0, DataStores.Store1, "WindowState", MemberTypes.Property);
                 GUI.m_APE.AddQueryMessageReflect(DataStores.Store1, DataStores.Store2, "ToString", MemberTypes.Method);
                 GUI.m_APE.AddRetrieveMessageGetValue(DataStores.Store2);
                 GUI.m_APE.SendMessages(EventSet.APE);
                 GUI.m_APE.WaitForMessages(EventSet.APE);
                 //Get the value(s) returned MUST be done straight after the WaitForMessages call
                 string windowState = GUI.m_APE.GetValueFromMessage();
                 return(windowState);
             }
             else
             {
                 if (NM.IsIconic(Handle))
                 {
                     return("Minimized");
                 }
                 else if (NM.IsZoomed(Handle))
                 {
                     return("Maximized");
                 }
                 else
                 {
                     return("Normal");
                 }
             }
         }
         else
         {
             throw GUI.ApeException("Form is not visible");
         }
     }
     else
     {
         throw GUI.ApeException("Form does not exist");
     }
 }