/// <summary>
        ///     Opens new window and attaches white's automation object to it.
        /// </summary>
        /// <param name="windowFactory">A factory method used to create new window</param>
        /// <param name="window">Returns created window</param>
        /// <param name="whiteWindow">Returns white's application for created window</param>
        public static void OpenWindow(Func <Window> windowFactory, out Window window,
                                      out White.Core.UIItems.WindowItems.Window whiteWindow)
        {
            var title = Guid.NewGuid().ToString();

            Window temporaryWindow = null;

            lock (typeof(GuiApplicationContainer))
            {
                EnsureApplicationIsRunning();
                Invoke(() =>
                {
                    temporaryWindow       = windowFactory();
                    temporaryWindow.Title = title;
                    temporaryWindow.Show();
                });
            }

            window      = temporaryWindow;
            whiteWindow = _whiteApplication.GetWindow(title, InitializeOption.NoCache);
            if (whiteWindow == null)
            {
                throw new InvalidStateException("whiteWindow cannot be null");
            }
        }
        static void Main(string[] args)
        {
            try
            {
                _application = White.Core.Application.Attach(Process.GetProcessesByName("iSystems 3.0")[0].Id);
                _mainWindow  = _application.GetWindow(SearchCriteria.ByText("iSystem Panel"), InitializeOption.NoCache);
                List <White.Core.UIItems.UIItem>    itm = new List <White.Core.UIItems.UIItem>();
                White.Core.UIItems.UIItemCollection xxx = _mainWindow.Items;

                foreach (White.Core.UIItems.UIItem i in xxx)
                {
                    if (i.ToString().StartsWith("Panel"))
                    {
                        foreach (White.Core.UIItems.UIItem Ucol in ((White.Core.UIItems.Panel)i).Items)
                        {
                            itm.Add(Ucol);
                        }
                    }
                    else if (i.ToString().StartsWith("GroupBox"))
                    {
                        foreach (White.Core.UIItems.UIItem Ucol in ((White.Core.UIItems.GroupBox)i).Items)
                        {
                            itm.Add(Ucol);
                        }
                    }
                }


                string s = ((White.Core.UIItems.ListBoxItems.Win32ComboBox)_mainWindow.Items[6]).SelectedItemText;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        /// Provides the Error on this UIItem. This would return Error object when this item has ErrorProvider displayed next to it.
        /// </summary>
        /// <param name="window"></param>
        /// <returns></returns>
        public virtual string ErrorProviderMessage(Window window)
        {
            AutomationElement element = AutomationElement.FromPoint(automationElement.Current.BoundingRectangle.ImmediateExteriorEast());

            if (element == null)
            {
                return(null);
            }
            Rect errorProviderBounds = element.Current.BoundingRectangle;

            if (automationElement.Current.BoundingRectangle.Right != errorProviderBounds.Left)
            {
                return(null);
            }
            mouse.Location = errorProviderBounds.Center();
            actionListener.ActionPerformed(Action.WindowMessage);
            return(window.ToolTip.Text);
        }
Exemple #4
0
        public void run_application()
        {
            var waitForApplicationStart = new ManualResetEvent(false);

            var thread = new Thread(() =>
            {
                _app          = new App();
                _app.Startup += (s, e) =>
                {
                    waitForApplicationStart.Set();
                };
                _app.Run();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            waitForApplicationStart.WaitOne();

            _dispatcher = Dispatcher.FromThread(thread);
            _dispatcher.Invoke(new ThreadStart(() => _window = _app.MainWindow as TestApp.Window));

            _whiteApp         = Application.Attach(Process.GetCurrentProcess());
            _windowAutomation = _whiteApp.GetWindow("MainWindow");
        }
Exemple #5
0
        public void run_application()
        {
            var waitForApplicationStart = new ManualResetEvent(false);

            var thread = new Thread(() =>
                                        {
                                            _app = new App();
                                            _app.Startup += (s, e) =>
                                                                {
                                                                    waitForApplicationStart.Set();
                                                                };
                                            _app.Run();
                                        });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            waitForApplicationStart.WaitOne();

            _dispatcher = Dispatcher.FromThread(thread);
            _dispatcher.Invoke(new ThreadStart(() => _window = _app.MainWindow as TestApp.Window));

            _whiteApp = Application.Attach(Process.GetCurrentProcess());
            _windowAutomation = _whiteApp.GetWindow("MainWindow");
        }
 public virtual void LocationChanged(Window window)
 {
     windowItemsMap.CurrentWindowPosition = window.Location;
 }
 public virtual void Register(Window window)
 {
     window.Focus();
     LocationChanged(window);
 }
 public virtual void Register(Window window)
 {
     window.Focus();
     LocationChanged(window);
 }
 public virtual void LocationChanged(Window window)
 {
     windowItemsMap.CurrentWindowPosition = window.Location;
 }
Exemple #10
0
 /// <summary>
 /// Provides the Error on this UIItem. This would return Error object when this item has ErrorProvider displayed next to it.
 /// </summary>
 /// <param name="window"></param>
 /// <returns></returns>
 public virtual string ErrorProviderMessage(Window window)
 {
     AutomationElement element =
         AutomationElement.FromPoint(automationElement.Current.BoundingRectangle.ImmediateExteriorEast());
     if (element == null) return null;
     Rect errorProviderBounds = element.Current.BoundingRectangle;
     if (automationElement.Current.BoundingRectangle.Right != errorProviderBounds.Left) return null;
     mouse.Location = errorProviderBounds.Center();
     actionListener.ActionPerformed(Action.WindowMessage);
     return window.ToolTip.Text;
 }