示例#1
0
        public void TestHasKeyboardFocusAfterPattern()
        {
            StackPanel panel = new StackPanel();
            ComboBox   fe    = CreateConcreteFrameworkElement() as ComboBox;

            fe.Items.Add("Item 0");
            fe.Items.Add("Item 1");

            Button button = new Button()
            {
                Content = "Button"
            };

            panel.Children.Add(fe);
            panel.Children.Add(button);

            AutomationPeer          buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(button);
            AutomationPeer          peer       = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            IExpandCollapseProvider provider   = null;

            CreateAsyncTest(panel,
                            () => {
                provider = (IExpandCollapseProvider)peer.GetPattern(PatternInterface.ExpandCollapse);
                Assert.IsNotNull(provider, "#1");
            },
                            () => provider.Expand(),
                            () => Assert.IsTrue(peer.HasKeyboardFocus(), "#2"),
                            () => button.Focus(),
                            () => Assert.IsTrue(buttonPeer.HasKeyboardFocus(), "#3"),
                            () => provider.Collapse(),
                            () => Assert.IsTrue(peer.HasKeyboardFocus(), "#4")
                            );
        }
示例#2
0
        public bool DoAction(int i)
        {
            if (i != 0)
            {
                return(false);
            }
            try {
                switch (expandCollapseProvider.ExpandCollapseState)
                {
                case ExpandCollapseState.Collapsed:
                    try {
                        expandCollapseProvider.Expand();
                    } catch (ElementNotEnabledException e) {
                        Log.Debug(e);
                        return(false);
                    }
                    break;

                case ExpandCollapseState.Expanded:
                    try {
                        expandCollapseProvider.Collapse();
                    } catch (ElementNotEnabledException e) {
                        Log.Debug(e);
                        return(false);
                    }
                    break;

                default:
                    throw new NotSupportedException("A combobox should not have an ExpandCollapseState different than Collapsed/Expanded");
                }
                return(true);
            } catch (ElementNotEnabledException) { }
            return(false);
        }
示例#3
0
        public static void SetWidthFromItems(this ComboBox comboBox)
        {
            double comboBoxWidth = 19;

            ComboBoxAutomationPeer  peer         = new ComboBoxAutomationPeer(comboBox);
            IExpandCollapseProvider provider     = (IExpandCollapseProvider)peer.GetPattern(PatternInterface.ExpandCollapse);
            EventHandler            eventHandler = null;

            eventHandler = new EventHandler(delegate
            {
                if (comboBox.IsDropDownOpen && comboBox.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                {
                    double width = 0;
                    foreach (var item in comboBox.Items)
                    {
                        ComboBoxItem comboBoxItem = comboBox.ItemContainerGenerator.ContainerFromItem(item) as ComboBoxItem;
                        comboBoxItem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                        if (comboBoxItem.DesiredSize.Width > width)
                        {
                            width = comboBoxItem.DesiredSize.Width;
                        }
                    }
                    comboBox.Width = comboBoxWidth + width;
                    comboBox.ItemContainerGenerator.StatusChanged -= eventHandler;
                    comboBox.DropDownOpened -= eventHandler;
                    provider.Collapse();
                }
            });
            comboBox.ItemContainerGenerator.StatusChanged += eventHandler;
            comboBox.DropDownOpened += eventHandler;
            provider.Expand();
        }
示例#4
0
        internal bool DoExpandCollapse()
        {
            if (expandCollapseProvider == null)
            {
                return(false);
            }

            ExpandCollapseState expandCollapseState
                = (ExpandCollapseState)Provider.GetPropertyValue(
                      ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty.Id);

            if (expandCollapseState == ExpandCollapseState.Expanded)
            {
                try {
                    expandCollapseProvider.Collapse();
                } catch (ElementNotEnabledException e) {
                    Log.Debug(e);
                    return(false);
                }
            }
            else
            {
                try {
                    expandCollapseProvider.Expand();
                } catch (ElementNotEnabledException e) {
                    Log.Debug(e);
                    return(false);
                }
            }

            return(true);
        }
示例#5
0
        static void ShowNextItem(TreeViewItem item)
        {
            var peer = new TreeViewItemAutomationPeer(item);
            IExpandCollapseProvider expander = peer;

            expander.Expand();
            InvokeUtility.DoEvents();
        }
        public virtual void TreeViewItemPeerExpandNoItems()
        {
            TreeViewItem item = new TreeViewItem();
            TreeViewItemAutomationPeer peer     = null;
            IExpandCollapseProvider    provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as TreeViewItemAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Expand());
        }
示例#7
0
        /// <summary>Displays all child nodes, controls, or content of the control.</summary>
        // Token: 0x06002872 RID: 10354 RVA: 0x000BC6AC File Offset: 0x000BA8AC
        void IExpandCollapseProvider.Expand()
        {
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = this.GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                IExpandCollapseProvider expandCollapseProvider = treeViewItemAutomationPeer;
                expandCollapseProvider.Expand();
                return;
            }
            base.ThrowElementNotAvailableException();
        }
        public virtual void ExpanderPeerExpands()
        {
            Expander item = new Expander();
            ExpanderAutomationPeer  peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Expand(),
                () => Assert.IsTrue(item.IsExpanded, "Item should be expanded!"));
        }
示例#9
0
        public virtual void AccordionItemPeerExpands()
        {
            AccordionItem item = new AccordionItem();
            AccordionItemAutomationPeer peer     = null;
            IExpandCollapseProvider     provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Expand(),
                () => Assert.IsTrue(item.IsSelected, "Item should be expanded!"));
        }
        public virtual void PickerPeerExpands()
        {
            Picker item = PickerInstance;
            PickerAutomationPeer    peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as PickerAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Expand(),
                () => Assert.IsTrue(item.IsDropDownOpen, "Item should be expanded!"));
        }
        ///
        void IExpandCollapseProvider.Expand()
        {
            TreeViewItemAutomationPeer wrapperPeer = GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (wrapperPeer != null)
            {
                IExpandCollapseProvider iExpandCollapseProvider = wrapperPeer as IExpandCollapseProvider;
                iExpandCollapseProvider.Expand();
            }
            else
            {
                ThrowElementNotAvailableException();
            }
        }
        public virtual void ExpanderPeerExpandDisabled()
        {
            Expander item = new Expander {
                IsEnabled = false
            };
            ExpanderAutomationPeer  peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ExpanderAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Expand());
        }
        public virtual void PickerPeerExpandDisabled()
        {
            Picker item = PickerInstance;

            item.IsEnabled = false;
            PickerAutomationPeer    peer     = null;
            IExpandCollapseProvider provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as PickerAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Expand());
        }
        ///For ComboBoxItem for which peer is this element only, scrolling should happen when the pop-up is expanded.
        internal override void RealizeCore()
        {
            ComboBox parent = ItemsControlAutomationPeer.Owner as ComboBox;

            if (parent != null)
            {
                IExpandCollapseProvider iecp = (IExpandCollapseProvider)UIElementAutomationPeer.FromElement(parent) as ComboBoxAutomationPeer;
                if (iecp.ExpandCollapseState != ExpandCollapseState.Expanded)
                {
                    iecp.Expand();
                }
            }
            base.RealizeCore();
        }
        // Token: 0x0600276E RID: 10094 RVA: 0x000B9FD8 File Offset: 0x000B81D8
        internal override void RealizeCore()
        {
            ComboBox comboBox = base.ItemsControlAutomationPeer.Owner as ComboBox;

            if (comboBox != null)
            {
                IExpandCollapseProvider expandCollapseProvider = ((IExpandCollapseProvider)UIElementAutomationPeer.FromElement(comboBox)) as ComboBoxAutomationPeer;
                if (expandCollapseProvider.ExpandCollapseState != ExpandCollapseState.Expanded)
                {
                    expandCollapseProvider.Expand();
                }
            }
            base.RealizeCore();
        }
        public virtual void TreeViewItemPeerExpandsExpanded()
        {
            TreeViewItem item = new TreeViewItem {
                IsExpanded = true, ItemsSource = new int[] { 1, 2, 3 }
            };
            TreeViewItemAutomationPeer peer     = null;
            IExpandCollapseProvider    provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as TreeViewItemAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.ExpandCollapse) as IExpandCollapseProvider,
                () => provider.Expand(),
                () => Assert.IsTrue(item.IsExpanded, "Item should be expanded!"));
        }
示例#17
0
        public void ExpandCollapseProvider_Methods()
        {
            bool             concreteLoaded        = false;
            bool             concreteLayoutUpdated = false;
            ComboBoxConcrete concrete = CreateConcreteFrameworkElement() as ComboBoxConcrete;

            concrete.Loaded        += (o, e) => concreteLoaded = true;
            concrete.LayoutUpdated += (o, e) => concreteLayoutUpdated = true;
            concrete.Items.Add(new ComboBoxItem()
            {
                Content = "1"
            });
            concrete.Items.Add(new ComboBoxItem()
            {
                Content = "2"
            });
            concrete.Width = 300;
            TestPanel.Children.Add(concrete);

            EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0");
            Enqueue(() => concrete.ApplyTemplate());
            Enqueue(() => {
                IExpandCollapseProvider expandCollapse = GetExpandCollapseProvider(concrete);
                Assert.AreEqual(ExpandCollapseState.Collapsed,
                                expandCollapse.ExpandCollapseState, "ExpandCollapseState #0");
                concreteLayoutUpdated = false;
                expandCollapse.Expand();
            });
            EnqueueConditional(() => concreteLayoutUpdated, "ConcreteLayoutUpdated #0");
            Enqueue(() => {
                // Test event
                IExpandCollapseProvider expandCollapse = GetExpandCollapseProvider(concrete);
                Assert.AreEqual(ExpandCollapseState.Expanded,
                                expandCollapse.ExpandCollapseState, "ExpandCollapseState #1");
                concreteLayoutUpdated = false;
                expandCollapse.Collapse();
            });
            EnqueueConditional(() => concreteLayoutUpdated, "ConcreteLayoutUpdated #1");
            Enqueue(() => {
                // Test event
                IExpandCollapseProvider expandCollapse = GetExpandCollapseProvider(concrete);
                Assert.AreEqual(ExpandCollapseState.Collapsed,
                                expandCollapse.ExpandCollapseState, "ExpandCollapseState #2");
                concreteLayoutUpdated = false;
            });
            EnqueueTestComplete();
        }
示例#18
0
        private bool DoClick()
        {
            if (invokeProvider != null)
            {
                try {
                    invokeProvider.Invoke();
                    return(true);
                } catch (ElementNotEnabledException e) {
                    Log.Debug(e);
                }
            }
            else if (expandCollapseProvider != null)
            {
                switch (expandCollapseProvider.ExpandCollapseState)
                {
                case ExpandCollapseState.Collapsed:
                    try {
                        expandCollapseProvider.Expand();
                    } catch (ElementNotEnabledException e) {
                        Log.Debug(e);
                        return(false);
                    }
                    return(true);

                case ExpandCollapseState.Expanded:
                    try {
                        expandCollapseProvider.Collapse();
                    } catch (ElementNotEnabledException e) {
                        Log.Debug(e);
                        return(false);
                    }
                    return(true);

                default:
                    // Should never happen
                    break;
                }
            }

            return(false);
        }
        public void ExpandCollapseProvider()
        {
            ToolStripSplitButton split_button = GetNewToolStripDropDownItem();
            ToolStripMenuItem    item         = new ToolStripMenuItem();
            ToolStrip            tool_strip   = new ToolStrip();

            tool_strip.Items.AddRange(new ToolStripItem[] { split_button });
            split_button.DropDownItems.AddRange(new ToolStripItem[] { item });
            Form.Controls.Add(tool_strip);

            tool_strip.Show();

            IRawElementProviderSimple provider = ProviderFactory.GetProvider(split_button);

            // Should always support ExpandCollapse
            IExpandCollapseProvider expandCollapseProvider
                = (IExpandCollapseProvider)provider.GetPatternProvider(
                      ExpandCollapsePatternIdentifiers.Pattern.Id);

            Assert.IsNotNull(expandCollapseProvider);

            Assert.AreEqual(ExpandCollapseState.Collapsed,
                            expandCollapseProvider.ExpandCollapseState);

            bridge.ResetEventLists();

            expandCollapseProvider.Expand();
            Assert.AreEqual(ExpandCollapseState.Expanded,
                            expandCollapseProvider.ExpandCollapseState);

            Assert.AreEqual(1, bridge.AutomationPropertyChangedEvents.Count);

            bridge.ResetEventLists();

            expandCollapseProvider.Collapse();
            Assert.AreEqual(ExpandCollapseState.Collapsed,
                            expandCollapseProvider.ExpandCollapseState);

            Assert.AreEqual(1, bridge.AutomationPropertyChangedEvents.Count);
        }
示例#20
0
        public static void SetWidthFromItems(this ComboBox comboBox)
        {
            const double comboBoxWidth = 19; // comboBox.DesiredSize.Width;

            // Create the peer and provider to expand the comboBox in code behind.
            ComboBoxAutomationPeer  peer         = new ComboBoxAutomationPeer(comboBox);
            IExpandCollapseProvider provider     = (IExpandCollapseProvider)peer.GetPattern(PatternInterface.ExpandCollapse);
            EventHandler            eventHandler = null;

            eventHandler = delegate
            {
                if (comboBox.IsDropDownOpen &&
                    comboBox.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                {
                    double width = 0;
                    foreach (var item in comboBox.Items)
                    {
                        ComboBoxItem comboBoxItem = comboBox.ItemContainerGenerator.ContainerFromItem(item) as ComboBoxItem;
                        if (comboBoxItem != null)
                        {
                            comboBoxItem.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                            if (comboBoxItem.DesiredSize.Width > width)
                            {
                                width = comboBoxItem.DesiredSize.Width;
                            }
                        }
                    }
                    comboBox.Width = comboBoxWidth + width;
                    // Remove the event handler.
                    comboBox.ItemContainerGenerator.StatusChanged -= eventHandler;
                    comboBox.DropDownOpened -= eventHandler;
                    provider?.Collapse();
                }
            };
            comboBox.ItemContainerGenerator.StatusChanged += eventHandler;
            comboBox.DropDownOpened += eventHandler;
            // Expand the comboBox to generate all its ComboBoxItem's.
            provider?.Expand();
        }
示例#21
0
        public void PatternsTest()
        {
            ComboBox combobox = GetComboBox();

            combobox.Items.Add("dummy 0");

            IRawElementProviderFragmentRoot rootProvider
                = (IRawElementProviderFragmentRoot)GetProviderFromControl(combobox);

            if (combobox.DropDownStyle == ComboBoxStyle.DropDownList)
            {
                throw new Exception("combobox default style should not be dropdownlist");
            }

            IExpandCollapseProvider     expandCollapseProvider = null;
            IRawElementProviderFragment listChild = null;

            bridge.ResetEventLists();
            combobox.DropDownStyle = ComboBoxStyle.DropDownList;
            Assert.IsTrue(bridge.StructureChangedEvents.Count > 0,
                          "Should generate some event after changing to ComboBoxStyle.DropDownList");
            Assert.IsNotNull(rootProvider.GetPatternProvider(SelectionPatternIdentifiers.Pattern.Id),
                             "DropDownList: Selection Pattern IS supported");
            expandCollapseProvider = (IExpandCollapseProvider)
                                     rootProvider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id);
            Assert.IsNotNull(expandCollapseProvider,
                             "DropDownList: ExpandCollapse Pattern IS supported");
            Assert.IsNull(rootProvider.GetPatternProvider(ValuePatternIdentifiers.Pattern.Id),
                          "DropDownList: ValuePattern Pattern IS NOT supported");

            listChild = rootProvider.Navigate(NavigateDirection.FirstChild);
            Assert.IsTrue((bool)listChild.GetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id),
                          "the list of a combobox should be offscreen if it's not expanded");
            expandCollapseProvider.Expand();
            Assert.IsFalse((bool)listChild.GetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id),
                           "the list of a combobox should not be offscreen if it's expanded");
            expandCollapseProvider.Collapse();
            Assert.IsTrue((bool)listChild.GetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id),
                          "the list of a combobox should be offscreen after collapsing");
            TestChildPatterns(rootProvider);

            bridge.ResetEventLists();
            combobox.DropDownStyle = ComboBoxStyle.DropDown;
            Assert.IsTrue(bridge.StructureChangedEvents.Count > 0,
                          "Should generate some event after changing to ComboBoxStyle.DropDown");
            Assert.IsNotNull(rootProvider.GetPatternProvider(SelectionPatternIdentifiers.Pattern.Id),
                             "DropDown: Selection Pattern IS supported");
            expandCollapseProvider = (IExpandCollapseProvider)
                                     rootProvider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id);
            Assert.IsNotNull(expandCollapseProvider,
                             "DropDown: ExpandCollapse Pattern IS supported");
            Assert.IsNotNull(rootProvider.GetPatternProvider(ValuePatternIdentifiers.Pattern.Id),
                             "DropDown: ValuePattern Pattern IS supported");
            TestChildPatterns(rootProvider);

            listChild = rootProvider.Navigate(NavigateDirection.FirstChild);
            Assert.IsTrue((bool)listChild.GetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id),
                          "the list of a combobox should be offscreen if it's not expanded");
            expandCollapseProvider.Expand();
            Assert.IsFalse((bool)listChild.GetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id),
                           "the list of a combobox should not be offscreen if it's expanded");
            expandCollapseProvider.Collapse();
            Assert.IsTrue((bool)listChild.GetPropertyValue(AutomationElementIdentifiers.IsOffscreenProperty.Id),
                          "the list of a combobox should be offscreen after collapsing");

            bridge.ResetEventLists();
            combobox.DropDownStyle = ComboBoxStyle.Simple;
            Assert.IsTrue(bridge.StructureChangedEvents.Count > 0,
                          "Should generate some event after changing to ComboBoxStyle.Simple");
            Assert.IsNotNull(rootProvider.GetPatternProvider(SelectionPatternIdentifiers.Pattern.Id),
                             "Simple: Selection Pattern IS supported");
            // LAMESPEC: ExpandCollapsePatternIdentifiers must always be implemented
            Assert.IsNull(rootProvider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id),
                          "Simple: ExpandCollapse Pattern IS NOT supported");
            Assert.IsNotNull(rootProvider.GetPatternProvider(ValuePatternIdentifiers.Pattern.Id),
                             "Simple: ValuePattern Pattern IS supported");
            TestChildPatterns(rootProvider);
        }
示例#22
0
 public void Expand()
 {
     provider.Expand();
 }
示例#23
0
        public void ExpandCollapseTest()
        {
            MainMenu mainMenu = new MainMenu();
            MenuItem item1    = new MenuItem("item1");

            SetupItemExpandCollapseEvents(item1);
            MenuItem item2         = new MenuItem("item2");
            MenuItem item1sub1     = new MenuItem("item1 sub1");
            MenuItem item1sub2     = new MenuItem("item1 sub2");
            MenuItem item1sub1sub1 = new MenuItem("item1 sub1 sub1");

            SetupItemExpandCollapseEvents(item1sub1);

            bool mainMenuCollapseEventRaised = false;

            mainMenu.Collapse += delegate(object sender, EventArgs e) {
                mainMenuCollapseEventRaised = true;
            };

            item1sub1.MenuItems.Add(item1sub1sub1);
            item1.MenuItems.Add(item1sub1);
            item1.MenuItems.Add(item1sub2);
            mainMenu.MenuItems.Add(item1);
            mainMenu.MenuItems.Add(item2);

            Form.Menu = mainMenu;

            IRawElementProviderSimple item1Provider =
                ProviderFactory.GetProvider(item1);
            IExpandCollapseProvider item1ExpandCollapse = (IExpandCollapseProvider)
                                                          item1Provider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id);

            item1ExpandCollapse.Expand();

            Assert.IsTrue(poppedupItems [item1]);
            Assert.IsTrue(selectedItems [item1]);
            Assert.IsFalse(clickedItems [item1]);
            Assert.IsFalse(mainMenuCollapseEventRaised);

            ClearExpandCollapseEvents();
            mainMenuCollapseEventRaised = false;

            IRawElementProviderSimple item1sub1Provider =
                ProviderFactory.GetProvider(item1sub1);
            IExpandCollapseProvider item1sub1ExpandCollapse = (IExpandCollapseProvider)
                                                              item1sub1Provider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id);

            item1sub1ExpandCollapse.Expand();

            Assert.IsTrue(poppedupItems [item1sub1]);
            Assert.IsTrue(selectedItems [item1sub1]);
            Assert.IsFalse(clickedItems [item1sub1]);
            Assert.IsFalse(mainMenuCollapseEventRaised);

            ClearExpandCollapseEvents();
            mainMenuCollapseEventRaised = false;

            item1sub1ExpandCollapse.Collapse();

            Assert.IsFalse(poppedupItems [item1sub1]);
            Assert.IsFalse(selectedItems [item1sub1]);
            Assert.IsFalse(clickedItems [item1sub1]);
            Assert.IsTrue(mainMenuCollapseEventRaised);

            ClearExpandCollapseEvents();
            mainMenuCollapseEventRaised = false;

            item1ExpandCollapse.Collapse();

            Assert.IsFalse(poppedupItems [item1]);
            Assert.IsFalse(selectedItems [item1]);
            Assert.IsFalse(clickedItems [item1]);
            Assert.IsTrue(mainMenuCollapseEventRaised);

            ClearExpandCollapseEvents();
            mainMenuCollapseEventRaised = false;
        }
示例#24
0
        private void demoMode() // DemoMode.DemoModeWindow demoModeWindow
        {
            #region unos učionice

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = "\nI - Dodavanje učionice\n"
                                                             + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber +
                                                             ". Kliknemo na dugme Dodaj učionicu u gornjem desnom uglu ekrana\n"
                                                             + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() => {
                ButtonAutomationPeer peer =
                    new ButtonAutomationPeer(dodajUcionicuDugme);
                IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke)
                                             as IInvokeProvider;

                peer.SetFocus();
                invokeProv.Invoke();
            });
            Thread.Sleep(3000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Kliknemo na polje identifikatora učionice\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() => {
                TextBoxAutomationPeer peer = new TextBoxAutomationPeer(ClassroomForma.Identificator);
                peer.SetFocus();
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Unesemo identifikator nove učionice\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() => { ClassroomForma.Identificator.Text = "L-52"; });
            Thread.Sleep(2000);

            Thread.Sleep(3000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Kliknemo na polje opisa učionice\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() => {
                TextBoxAutomationPeer peer = new TextBoxAutomationPeer(ClassroomForma.Description);
                peer.SetFocus();
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Unesemo opis učionice\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() => { ClassroomForma.Description.Text = "Opis učionice"; });
            Thread.Sleep(2000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Unesemo broj radnika\n\n" + demoModeWindow.currentDemoDescription.Text;
            });
            Thread.Sleep(2500);

            Dispatcher.Invoke(() => { ClassroomForma.brojMijestaUpDown.Value = 3; });
            Thread.Sleep(2000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Odaberemo operativni sistem\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() => {
                ComboBoxAutomationPeer peer = new ComboBoxAutomationPeer(ClassroomForma.OperatingSystem);
                peer.SetFocus();
                IExpandCollapseProvider provider = (IExpandCollapseProvider)
                                                   peer.GetPattern(PatternInterface.ExpandCollapse);
                provider.Expand();
            });

            Thread.Sleep(2000);

            Dispatcher.Invoke(() => { ClassroomForma.OperatingSystem.SelectedIndex = 2; });

            Thread.Sleep(2000);

            Dispatcher.Invoke(() => {
                ComboBoxAutomationPeer peer = new ComboBoxAutomationPeer(ClassroomForma.OperatingSystem);
                peer.SetFocus();
                IExpandCollapseProvider provider = (IExpandCollapseProvider)
                                                   peer.GetPattern(PatternInterface.ExpandCollapse);
                provider.Collapse();
            });

            Thread.Sleep(3000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Odaberemo instalirani softver iz liste\n\n" + demoModeWindow.currentDemoDescription.Text;
            });
            Thread.Sleep(5500);

            Dispatcher.Invoke(() => {
                ListBoxAutomationPeer peer = new ListBoxAutomationPeer(ClassroomForma.SoftwaresList);
                peer.SetFocus();
                ClassroomForma.SoftwaresList.SelectedIndex = 2;
            });
            Thread.Sleep(2000);
            Dispatcher.Invoke(() => { ClassroomForma.SoftwaresList.SelectedIndex = 4; });

            Thread.Sleep(3000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Označimo opremu koja postoji. Tablu nemamo, ali imamo projektor\n\n" + demoModeWindow.currentDemoDescription.Text;
            });
            Thread.Sleep(5500);

            Dispatcher.Invoke(() => {
                ClassroomForma.TableNeeded.IsChecked     = false;
                ClassroomForma.ProjectorNeeded.IsChecked = true;
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Potvrdimo unos\n\n" + demoModeWindow.currentDemoDescription.Text;
            });
            Thread.Sleep(3000);
            Dispatcher.Invoke(() =>
            {
                ButtonAutomationPeer peer =
                    new ButtonAutomationPeer(ClassroomForma.Potvrda);
                peer.SetFocus();
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() =>
            {
                ButtonAutomationPeer peer  = new ButtonAutomationPeer(ClassroomForma.Potvrda);
                IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                invokeProv.Invoke();

                demoModeWindow.demoNumber = 0;
            });

            Thread.Sleep(1000);
            Console.WriteLine("444444444444");

            #endregion unos učionice

            #region pregled učionica
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = "\nII Pregled učionica\n\n" +
                                                             demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber +
                                                             ". Odaberemo meni Tabele\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);


            Dispatcher.Invoke(() =>
            {
                MenuItemAutomationPeer peer =
                    new MenuItemAutomationPeer(this.MeniTabele);

                IExpandCollapseProvider provider = (IExpandCollapseProvider)
                                                   peer.GetPattern(PatternInterface.ExpandCollapse);
                provider.Expand();
            });

            Thread.Sleep(2000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber + ". Odaberemo stavku Učionice\n\n"
                                                             + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(2000);

            Dispatcher.Invoke(() =>
            {
                MenuItemAutomationPeer peer = new MenuItemAutomationPeer(this.MeniItemUcionice);
                peer.SetFocus();
            });

            Thread.Sleep(2000);

            Dispatcher.Invoke(() =>
            {
                MenuItemAutomationPeer peer = new MenuItemAutomationPeer(this.MeniItemUcionice);
                IInvokeProvider invokeProv  = peer.GetPattern(PatternInterface.Invoke)
                                              as IInvokeProvider;

                peer.SetFocus();
                invokeProv.Invoke();
            });

            Thread.Sleep(2000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber + ". Sada vidimo tabelu sa učionicama" +
                                                             " gdje možemo svaku od njih obrisati ili izmijeniti\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            #endregion

            #region izmjena učionice
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = "\nIII Izmjena učionice\n\n" +
                                                             demoModeWindow.currentDemoDescription.Text;
            });
            Thread.Sleep(4000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber +
                                                             ". Izmijenićemo jednu učionicu, klikom na dugme Izmijeni u prvom redu\n\n" +
                                                             demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(4000);
            Dispatcher.Invoke(() =>
            {
                this.ClassroomTabela.ClassroomsList.SelectedItem = 1;
                ClassroomHandler.Instance.SetSelectedClassroom(ClassroomTabela.Classrooms[0], (MainWindow)Window.GetWindow(this));
                ((MainWindow)Window.GetWindow(this)).NovaUcionica_Show();
            });
            Thread.Sleep(4000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Kliknemo na polje opisa učionice\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() => {
                TextBoxAutomationPeer peer = new TextBoxAutomationPeer(ClassroomForma.Description);
                peer.SetFocus();
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Unesemo novi opis učionice\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() => { ClassroomForma.Description.Text = "Novi opis za L-42"; });

            Thread.Sleep(3000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Izmijenimo postojeću opremu. Kupili smo pametnu tablu.\n\n" + demoModeWindow.currentDemoDescription.Text;
            });
            Thread.Sleep(5000);

            Dispatcher.Invoke(() => {
                ClassroomForma.SmartTableNeeded.IsChecked = true;
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber
                                                             + ". Potvrdimo unos.\n\n" + demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);
            Dispatcher.Invoke(() =>
            {
                ButtonAutomationPeer peer =
                    new ButtonAutomationPeer(ClassroomForma.Potvrda);
                peer.SetFocus();
            });

            Thread.Sleep(2000);
            Dispatcher.Invoke(() =>
            {
                ButtonAutomationPeer peer  = new ButtonAutomationPeer(ClassroomForma.Potvrda);
                IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                invokeProv.Invoke();
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber +
                                                             ". Nakon unosa ponovo vidimo prikaz svih učionica, te možemo vidjeti " +
                                                             "da je njen identifikator izmijenjen.\n\n" + demoModeWindow.currentDemoDescription.Text;

                demoModeWindow.demoNumber = 0;
            });

            Thread.Sleep(5000);
            #endregion

            #region brisanje učionice
            Dispatcher.Invoke(() =>
            {
                demoModeWindow.demoNumber = 0;
                demoModeWindow.currentDemoDescription.Text = "\nIV Brisanje učionice\n\n" +
                                                             demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(3000);

            Dispatcher.Invoke(() =>
            {
                demoModeWindow.currentDemoDescription.Text = demoModeWindow.demoNumber +
                                                             ". Obrisaćemo jednu učionicu, recimo prvu, klikom na dugme Obriši u prvom redu\n\n" +
                                                             demoModeWindow.currentDemoDescription.Text;
            });

            Thread.Sleep(4000);
            Dispatcher.Invoke(() =>
            {
                this.ClassroomTabela.ClassroomsList.SelectedItem = 1;
                ClassroomHandler.Instance.SetSelectedClassroom(ClassroomTabela.Classrooms[0], (MainWindow)Window.GetWindow(this));
                ClassroomHandler.Instance.Remove(ClassroomHandler.Instance.SelectedClassroom.Id, (MainWindow)Window.GetWindow(this));
            });
            Thread.Sleep(4000);
            #endregion
        }
示例#25
0
 void IExpandCollapseProvider.Expand() => publicIExpandCollapseProvider.Expand();
示例#26
0
        public void DatePicker_AutomationPeer()
        {
            _elementToCleanUp = new DatePicker();
            _isLoaded         = false;
            DatePickerAutomationPeer datePickerAutomationPeer = (DatePickerAutomationPeer)DatePickerAutomationPeer.CreatePeerForElement(_elementToCleanUp);

            Assert.IsNotNull(datePickerAutomationPeer);

            DateTime date = new DateTime(2000, 2, 2);

            _elementToCleanUp.SelectedDate = date;
            _elementToCleanUp.Height       = 30;
            _elementToCleanUp.Width        = 100;
            _elementToCleanUp.Loaded      += new RoutedEventHandler(_elementToCleanUp_Loaded);
            TestPanel.Children.Add(_elementToCleanUp);
            EnqueueConditional(IsLoaded);
            DateTime date2 = new DateTime(2000, 5, 5);

            EnqueueCallback(delegate
            {
                Assert.AreEqual(datePickerAutomationPeer.GetAutomationControlType(), AutomationControlType.ComboBox, "Incorrect Control type for datepicker");
                Assert.AreEqual(datePickerAutomationPeer.GetClassName(), _elementToCleanUp.GetType().Name, "Incorrect ClassName value for datepicker");
                Assert.AreEqual(datePickerAutomationPeer.GetName(), date.ToString(), "Incorrect Name value for datepickerpeer");
                Assert.IsTrue(datePickerAutomationPeer.IsContentElement(), "Incorrect IsContentElement value");
                Assert.IsTrue(datePickerAutomationPeer.IsControlElement(), "Incorrect IsControlElement value");

                #region DatePickerAutomationPeer IExpandCollapseProvider tests:

                IExpandCollapseProvider datePickerExpandCollapseProvider = ((IExpandCollapseProvider)datePickerAutomationPeer.GetPattern(PatternInterface.ExpandCollapse));
                Assert.IsNotNull(datePickerAutomationPeer);
                Assert.AreEqual(datePickerExpandCollapseProvider.ExpandCollapseState, ExpandCollapseState.Collapsed);
                _elementToCleanUp.IsDropDownOpen = true;
                Assert.IsTrue(_elementToCleanUp.TestHook.DropDown.IsOpen);
                Assert.AreEqual(datePickerExpandCollapseProvider.ExpandCollapseState, ExpandCollapseState.Expanded);
                datePickerExpandCollapseProvider.Collapse();
                Assert.AreEqual(datePickerExpandCollapseProvider.ExpandCollapseState, ExpandCollapseState.Collapsed);
                Assert.IsFalse(_elementToCleanUp.TestHook.DropDown.IsOpen);
                datePickerExpandCollapseProvider.Expand();
                Assert.IsTrue(_elementToCleanUp.TestHook.DropDown.IsOpen);
                Assert.AreEqual(datePickerExpandCollapseProvider.ExpandCollapseState, ExpandCollapseState.Expanded);
                datePickerExpandCollapseProvider.Collapse();

                #endregion

                #region DatePickerAutomationPeer IValueProvider tests:

                IValueProvider datePickerValueProvider = ((IValueProvider)datePickerAutomationPeer.GetPattern(PatternInterface.Value));
                Assert.IsNotNull(datePickerValueProvider);
                Assert.IsFalse(datePickerValueProvider.IsReadOnly);
                Assert.AreEqual(datePickerValueProvider.Value, date.ToString());
                _elementToCleanUp.SelectedDate = null;
                Assert.AreEqual(datePickerValueProvider.Value, string.Empty);
                datePickerValueProvider.SetValue(date2.ToString());
                Assert.AreEqual(_elementToCleanUp.SelectedDate, date2);
                Assert.AreEqual(datePickerValueProvider.Value, date2.ToString());
                #endregion
            });
            EnqueueSleep(sleepTime);
            EnqueueCallback(delegate
            {
                Assert.AreEqual(_elementToCleanUp.Text, date2.ToString("d"));
            });

            EnqueueTestComplete();
        }