Ejemplo n.º 1
0
        public void InvokeTest()
        {
            Button button = new Button();
            IRawElementProviderSimple provider       = ProviderFactory.GetProvider(button);
            IInvokeProvider           invokeProvider = (IInvokeProvider)
                                                       provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);

            bool buttonClicked = false;

            button.Click += delegate(object sender, EventArgs e) {
                buttonClicked = true;
            };

            invokeProvider.Invoke();
            Assert.IsTrue(buttonClicked,
                          "Click should fire when button is enabled");

            buttonClicked  = false;
            button.Enabled = false;
            try {
                invokeProvider.Invoke();
                Assert.Fail("Expected ElementNotEnabledException");
            } catch (ElementNotEnabledException) {
                // Awesome, this is expected
            } catch (Exception e) {
                Assert.Fail("Expected ElementNotEnabledException, " +
                            "but got exception with message: " +
                            e.Message);
            }
            Assert.IsFalse(buttonClicked,
                           "Click should not fire when button is disabled");
        }
        public void InvokeTest()
        {
            T menuItem = item;
            IRawElementProviderSimple provider       = ProviderFactory.GetProvider(menuItem);
            IInvokeProvider           invokeProvider = (IInvokeProvider)
                                                       provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);

            ToolStripItem   childItem           = menuItem.DropDownItems.Add("testchild");
            var             childItemProvider   = ProviderFactory.GetProvider(childItem);
            IInvokeProvider childInvokeProvider = (IInvokeProvider)
                                                  childItemProvider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);

            bool childItemClicked = false;

            childItem.Click += delegate(object sender, EventArgs e) {
                childItemClicked = true;
            };
            childInvokeProvider.Invoke();
            Assert.IsFalse(childItemClicked,
                           "Should fail when invoking child " +
                           "without first showing parent");

            bool itemClicked = false;

            menuItem.Click += delegate(object sender, EventArgs e) {
                itemClicked = true;
            };

            invokeProvider.Invoke();
            Assert.IsTrue(itemClicked,
                          "Click should fire when button is enabled");
            if (menuItem is ToolStripSplitButton)
            {
                ((IExpandCollapseProvider)provider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id)).Expand();
            }
            childInvokeProvider.Invoke();
            Assert.IsTrue(childItemClicked,
                          "Invoking child should work after first showing parent");

            itemClicked      = false;
            menuItem.Enabled = false;
            try {
                invokeProvider.Invoke();
                Assert.Fail("Expected ElementNotEnabledException");
            } catch (ElementNotEnabledException) {
                // Awesome, this is expected
            } catch (Exception e) {
                Assert.Fail("Expected ElementNotEnabledException, " +
                            "but got exception with message: " +
                            e.Message);
            }
            Assert.IsFalse(itemClicked,
                           "Click should not fire when button is disabled");
        }
Ejemplo n.º 3
0
        public void InvokeProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            TestPanel.Children.Clear();
            datagrid = CreateDataGrid();
            IInvokeProvider      provider = null;
            AutomationEventTuple tuple    = null;
            AutomationPeer       peer     = null;

            CreateAsyncTest(datagrid,
                            () => {
                peer     = GetDataGridColumnHeader(datagrid);
                provider = (IInvokeProvider)peer.GetPattern(PatternInterface.Invoke);
                Assert.IsNotNull(provider, "GetPattern #0");
                EventsManager.Instance.Reset();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.InvokePatternOnInvoked);
                Assert.IsNull(tuple, "GetAutomationEventFrom #0");
                provider.Invoke();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.InvokePatternOnInvoked);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #1");
            });
        }
Ejemplo n.º 4
0
        private async void DataGridSearched_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGrid dgv = (DataGrid)sender;
            ProductSearchResultModel model = (ProductSearchResultModel)dgv.SelectedItem;

            if (model != null)
            {
                string messageText = "";
                if (model.IsFavorite == "-")
                {
                    messageText = "Добавить товар \"" + model.ProductName + " \" в избранное?";
                }
                else
                {
                    messageText = "Убрать товар \"" + model.ProductName + " \" из избранного?";
                }
                var result = MessageBox.Show(messageText, "Внимание!", MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    await dbLoader.SaveFavoriteAsync(model);

                    ButtonAutomationPeer peer       = new ButtonAutomationPeer(ButtonSearch);
                    IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                    invokeProv.Invoke();
                }
            }
        }
Ejemplo n.º 5
0
        // Called when the hover action has finished, and the button should be pressed
        private void Cursor_HoverFinished(object sender, EventArgs e)
        {
            // Using the automation provider to invoke the button is the only way to really emulate a mouse clicking on it in WPF.
            _invoker.Invoke();

            ((KinectCursor)sender).HoverFinished -= Cursor_HoverFinished;
        }
Ejemplo n.º 6
0
        private void UIAutomationButtonClick()
        {
            ButtonAutomationPeer btnAutomationPeer = new ButtonAutomationPeer(btn);
            IInvokeProvider      provider          = btnAutomationPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            provider.Invoke();
        }
        private void computerMakeMove()
        {
            //priority1 get tic tac toe
            //priority2 block x's tic tac toe
            //priority3 go for open space
            //priority4 pick corner

            Button move = null;

            move = lookForMoveOrBlock("O");
            if (move == null)
            {
                move = lookForMoveOrBlock("X");
                if (move == null)
                {
                    move = lookForCorner();
                }
                if (move == null)
                {
                    move = lookForOpenSpace();
                }
            }

            ButtonAutomationPeer peer       = new ButtonAutomationPeer(move);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 8
0
        private void Listening_Click(object sender, RoutedEventArgs e)
        {
            // Start Server
            string IP = HostIP.Text;

            playerNum = int.Parse(gameNumBox.Text);
            Thread thread = new Thread(delegate()
            {
                doServer(IP, this.playerNum);
            });

            thread.Start();

            // Start Client
            ClientJoin cJoin = new ClientJoin();

            cJoin.Show();
            cJoin.textIP.Text   = IP;
            cJoin.textName.Text = this.gameID.Text;
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(cJoin.btnConnect);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
            this.Close();
        }
Ejemplo n.º 9
0
        private void ClickWPFbutton(System.Windows.Controls.Button b)
        {
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(b);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 10
0
        private void ClickButton(Button button)
        {
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(button);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 11
0
        private void DialogHost_OnDialogClosing(object sender, DialogClosingEventArgs eventArgs)
        {
            //Console.WriteLine("SAMPLE 1: Closing dialog with parameter: " + (eventArgs.Parameter ?? ""));

            //you can cancel the dialog close:
            //eventArgs.Cancel();


            if (!Equals(eventArgs.Parameter, true))
            {
                return;
            }

            GlobalUser.DoAnswer = false;
            //GlobalUser.AudioCleanUp(); //关闭音频播放
            (this.DataContext as ExamCommonVM)?.Dispose();
            this.DataContext = null;

            ButtonAutomationPeer peer =
                new ButtonAutomationPeer(CloseBtn);

            IInvokeProvider invokeProv =
                peer.GetPattern(PatternInterface.Invoke)
                as IInvokeProvider;

            invokeProv.Invoke();

            //CloseBtn.RaiseEvent(new RoutedEventArgs(System.Windows.Controls.Button.ClickEvent));
        }
Ejemplo n.º 12
0
        private void BtnGo_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(TbTarget.Text) && Directory.Exists(TbTarget.Text))
            {
                Process.Start(TbTarget.Text);
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("No folder has been found, want to execute the program?", App.Current.MainWindow.Title, MessageBoxButton.YesNoCancel);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    ButtonAutomationPeer peer       = new ButtonAutomationPeer(BtRun);
                    IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                    invokeProv.Invoke();
                    LbResult.Content = $"Executed";
                    break;

                case MessageBoxResult.No:
                    LbResult.Content = $"The target folder on Output doesn't exists";
                    break;

                case MessageBoxResult.Cancel:
                    LbResult.Content = $"The target folder on Output doesn't exists";
                    break;
                }
            }
        }
Ejemplo n.º 13
0
        protected void Test_InvokeProvider_Invoke(ButtonBase button)
        {
            AutomationPeer peer
                = FrameworkElementAutomationPeer.CreatePeerForElement(button);
            IInvokeProvider invoke = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            Assert.IsNotNull(invoke, "InvokeProvider is null");

            invoke.Invoke();
            button.IsEnabled = false;

            Assert.Throws <ElementNotEnabledException> (() => invoke.Invoke());

            button.IsEnabled = true;
            invoke.Invoke();
        }
Ejemplo n.º 14
0
        public void EmulateClick()
        {
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(Core);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 15
0
        public int generateRandomComputerMove(List <Button> buttonList)
        {
            Random random = new Random();

            for (int i = 0; i < buttonList.Count; i++)
            {
                if (buttonList[i].IsEnabled == true)
                {
                    countButtonsAvailable++;
                    buttonListAfterRemove.Add(buttonList.ElementAt(i));
                }
            }

            lenghtOfList = buttonListAfterRemove.Count;
            randInt      = random.Next(0, lenghtOfList);

            string numberOfButtonClicked = buttonListAfterRemove[randInt].Name;//Um zu übergeben welcher button gedrückt wird;

            //MessageBox.Show(buttonListAfterRemove[randInt].Name);
            ButtonAutomationPeer peer =
                new ButtonAutomationPeer(buttonListAfterRemove[randInt]);
            IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();

            buttonListAfterRemove = new List <Button>();
            //MessageBox.Show("random");

            return((int)Char.GetNumericValue(numberOfButtonClicked[3]) - 1);
        }
Ejemplo n.º 16
0
        private void modsTxt_MouseUp(object sender, MouseButtonEventArgs e)
        {
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(modsBtn);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 17
0
        private void flashStoryboard_Completed(object sender, EventArgs e)
        {
            // Tell the storyboard to officially stop once is has animated itself (otherwise you could
            // suspend, resume, etc. and not start another animation using this same storyboard until
            // truly stopping this one which is what we want to do).
            flashStoryboard.Stop();
            flashStoryboard.Completed -= flashStoryboard_Completed;
            flashStoryboard            = null;

            // If the button we are animating is the "Browse" button and the side panel containing the "Browse Control" is created and it
            // is visible and if the current tab selected on this side panel is already the one we want, then exit. Otherwise, invoke
            // the button programmatically as usual.
            if (animatingButton.Name == "BrowseMenuButton" && sidePanel != null && sidePanel.Visibility == System.Windows.Visibility.Visible)
            {
                TabItem ti = (TabItem)sidePanel.SelectedItem;
                if (ti.Name == "BrowseTabItem")
                {
                    animatingButton = null;
                    return;
                }
            }

            // Simulate clicking the target button
            ButtonAutomationPeer peer = new ButtonAutomationPeer((Button)animatingButton);
            IInvokeProvider      ip   = (IInvokeProvider)peer;

            ip.Invoke();

            // Reset which button is being animated so another may be animated
            animatingButton = null;
        }
Ejemplo n.º 18
0
        public void InvokedEventTest()
        {
            IRawElementProviderSimple provider = GetProvider();

            bridge.ResetEventLists();

            //we cannot do this, there's no PerformClick() API in toolbarButton:
            //toolBarButton.PerformClick ();
            //so we use the provider:
            IInvokeProvider invokeProvider =
                (IInvokeProvider)provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);

            invokeProvider.Invoke();

            Assert.AreEqual(1,
                            bridge.AutomationEvents.Count,
                            "event count");

            AutomationEventTuple eventInfo =
                bridge.AutomationEvents [0];

            Assert.AreEqual(InvokePatternIdentifiers.InvokedEvent,
                            eventInfo.eventId,
                            "event type");
            Assert.AreEqual(provider,
                            eventInfo.provider,
                            "event element");
            Assert.AreEqual(InvokePatternIdentifiers.InvokedEvent,
                            eventInfo.e.EventId,
                            "event args event type");
        }
Ejemplo n.º 19
0
        private void startTxtClick(object sender, MouseButtonEventArgs e)
        {
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(startBtn);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 20
0
        public static void AutomationPeerInvoke(this Button button)
        {
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(button);
            IInvokeProvider      invokeProv = (IInvokeProvider)peer.GetPattern(PatternInterface.Invoke);

            invokeProv.Invoke();
        }
Ejemplo n.º 21
0
        private void PINTabItem_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                e.Handled = true;
                typeof(Button).GetMethod("set_IsPressed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(PinLoginButton, new object[] { true });
                var             peer       = UIElementAutomationPeer.CreatePeerForElement(PinLoginButton);
                IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

                invokeProv.Invoke();
                return;
            }
            var isNumber = e.Key >= Key.D0 && e.Key <= Key.D9;
            var isKeyPad = e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9;

            if (isNumber || isKeyPad)
            {
                int value = -1;
                if (isNumber)
                { // numpad
                    value = (int)e.Key - ((int)Key.D0);
                }
                else if (isKeyPad)
                { // regular numbers
                    value = (int)e.Key - ((int)Key.NumPad0);
                }
                PinBox.Password = PinBox.Password + value.ToString();
                e.Handled       = true;
            }
            else
            {
                e.Handled = true;
            }
        }
Ejemplo n.º 22
0
        public static void ExecuteClick(this MenuItem menuItem)
        {
            MenuItemAutomationPeer peer       = new MenuItemAutomationPeer(menuItem);
            IInvokeProvider        invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
        protected static void InvokeButton(ButtonBase button)
        {
            ButtonBaseAutomationPeer buttonPeer           = ButtonBaseAutomationPeer.CreatePeerForElement(button) as ButtonBaseAutomationPeer;
            IInvokeProvider          buttonInvokeProvider = buttonPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            buttonInvokeProvider.Invoke();
        }
Ejemplo n.º 24
0
        private void ReleasesButtonWPF_Click(object sender, RoutedEventArgs e)
        {
            TransferInfo.tableContent = "Releases";
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(HiddenButtonForTablesWPF);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 25
0
        public void IInvokeProvider_Invoke()
        {
            DataGridColumnHeader fe   = CreateConcreteFrameworkElement() as DataGridColumnHeader;
            AutomationPeer       peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);

            IInvokeProvider invoke = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            Assert.IsNotNull(invoke, "InvokeProvider is null");

            invoke.Invoke();
            fe.IsEnabled = false;

            invoke.Invoke();

            fe.IsEnabled = true;
            invoke.Invoke();
        }
Ejemplo n.º 26
0
        private void RemoveMenuItem_Click(object sender, EventArgs e)
        {
            // tab will be focused (because of right-click handler), so just invoke "remove" button
            ButtonAutomationPeer peer       = new ButtonAutomationPeer(Remove);
            IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 27
0
        /****************************************************************
         * Public Methods
         **/
        /// <summary>
        /// Trigger Show Picker
        /// </summary>
        public void ClickTemplateButton()
        {
            Button button                 = (GetTemplateChild("DateTimeButton") as Button);
            ButtonAutomationPeer peer     = new ButtonAutomationPeer(button);
            IInvokeProvider      provider = (peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider);

            provider.Invoke();
        }
Ejemplo n.º 28
0
        public static void ClickButton(ButtonBase button)
        {
            ButtonBaseAutomationPeer peer    = FrameworkElementAutomationPeer.CreatePeerForElement(button) as ButtonBaseAutomationPeer;
            IInvokeProvider          invoker = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invoker.Invoke();
            DispatcherHelper.UpdateLayoutAndDoEvents(button);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Launch the record when the waiting time is over
        /// </summary>
        public void launchRecordingAfterWait()
        {
            inRecord = true;

            allFalse();
            if (FaceRecognition == true)
            {
                TrackingSideToolViewModel tracking = TrackingSideToolViewModel.get();
                tracking.FaceTracking = true;
                tracking.emo          = true;
                //tracking.Mouth = true;
                //tracking.Mouth2 = true; //Those feature are not working for now
                //tracking.pupilR = true;
                tracking.LookR = true;
            }
            if (VoiceRecognition == true)
            {
                TrackingSideToolViewModel tracking = TrackingSideToolViewModel.get();
                //tracking.PeakDetection = true; //Create lags when in record
                tracking.SpeedRate        = true;
                tracking.ShowTextOnScreen = true;

                /*tracking.VoiceMonotony = true;
                 * tracking.BadVoiceReflex = true;*///Features are not working
            }
            if (BodyRecognition == true)
            {
                TrackingSideToolViewModel.get().UseFeedback = true;
            }

            SideToolsViewModel.Get().chooseTraining();

            TrainingSideToolViewModel tstvm = TrainingSideToolViewModel.Get();

            tstvm.limitedTimeHours   = "0";
            tstvm.limitedTimeMinutes = MinRecord.ToString();
            tstvm.limitedTimeSeconds = SecRecord.ToString();
            tstvm.isTimeLimited      = true;

            /*Depending on which view the user was using when he start his session record
             * the session recording will record the view the user was using*/
            if (MainWindow.drawingSheet.getMode() == SheetMode.AvatarMode)
            {
                tstvm.ToggleAvatarOpenGLRecording = true;
            }
            else if (MainWindow.drawingSheet.getMode() == SheetMode.StreamMode)
            {
                tstvm.ToggleStreamRecording = true;
            }
            tstvm.ToggleAudioRecording = true;

            //Launch the record
            ButtonAutomationPeer peer = new ButtonAutomationPeer(TrainingSideTool.Get().StartRecordingButton);

            IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

            invokeProv.Invoke();
        }
Ejemplo n.º 30
0
        public void LoadConfig()
        {
            List <string> config = new List <string>();

            if (!File.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\config.txt"))
            {
                File.Create($"{AppDomain.CurrentDomain.BaseDirectory}\\config.txt");

                return;
            }

            config = File.ReadAllLines($"{AppDomain.CurrentDomain.BaseDirectory}\\config.txt").ToList();

            if (config.Count == 0)
            {
                return;
            }

            for (int i = 0; i < config.Count; i++)
            {
                config[i] = config[i].Split(new string[] { "=" }, StringSplitOptions.None)[1];
            }

            cfg_val = config;

            int load_ram = int.Parse(config[(int)PropertySettings.MC_RAM]);

            if (load_ram > MAX_RAM)
            {
                mcRam.Text = MAX_RAM.ToString();
            }
            else
            {
                mcRam.Text = load_ram.ToString();
            }

            mcPath.Text = config[(int)PropertySettings.MC_PATH];

            if (mcPath.Text == "")
            {
                mcPath.Text = mine.GetDefaultPath();
            }

            mine.PATH = mcPath.Text;

            if (bool.Parse(config[(int)PropertySettings.ID_SAVE]))
            {
                IDsave.IsChecked = true;
                ID.Text          = config[(int)PropertySettings.ID];
                PWD.Password     = config[(int)PropertySettings.PWD];

                ButtonAutomationPeer peer       = new ButtonAutomationPeer(LoginBtn);
                IInvokeProvider      invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                invokeProv.Invoke();
            }

            G.InfoLog("Load Config Success");
        }