Beispiel #1
0
        private void PressPrompt(WidgetCollection widgets, Widget label)
        {
            if (ArePromptLocationsCorrect(widgets))
            {
                Widget promptBox = widgets.FindByLabel(label, WidgetType.Button);
                _controlPanel.Press(promptBox);
            }
            else
            {
                if (AreTextBoxLocationsCorrect(widgets))
                {
                    // For some devices, the workflow parameters screen reports the same bounding box for each label, which
                    // makes it impossible to determine which label corresponds to which text box by comparing their position.
                    // Instead, we are forced to make an assumption based on the way the controls are dynamically created:
                    // each text box corresponds to the prompt with an ID exactly 1 greater than the box's ID.
                    _controlPanel.Press(label.Id - 1);
                }
                else
                {
                    // On the workflow parameters screen, the bounding boxes are the same for all the labels AND text boxes.
                    // We'll need to make some assumptions about the way the controls are dynamically created:
                    // Each text box corresponds to the prompt with an ID exactly 1 greater than the box's ID,
                    // AND the text box IDs are in ascending order as we move down the screen.
                    int textBoxId = label.Id - 1;

                    // Calculate the y offset from the top box's press coordinate.
                    // There are 50 pixels between each edit box and the ID increments by 2 for each box.
                    // The top box always has ID 1500
                    Widget topBox       = widgets.Find(1500);
                    var    topBoxCenter = new Coordinate(topBox.Location.X + topBox.Size.Width / 2, topBox.Location.Y + topBox.Size.Height / 2);
                    int    offset       = (textBoxId - topBox.Id) / 2 * 50;
                    _controlPanel.PressScreen(new Coordinate(topBoxCenter.X, topBoxCenter.Y + offset));
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Enables email notification for this job.
        /// </summary>
        /// <param name="condition">The condition under which to send notification.</param>
        /// <param name="address">The email address to receive the notification.</param>
        /// <param name="thumbNail">if set to<c>true>enable thumbnail;otherwise,disable it</c></param>//We have added thumbnail parameter but not yet implemented it
        public void EnableEmailNotification(NotifyCondition condition, string address, bool thumbNail)
        {
            Widget serviceButton = ScrollToOption("Notification");

            Pacekeeper.Sync();
            _controlPanel.Press(serviceButton);
            Pacekeeper.Sync();

            // Press the notify option, then wait for the other widgets to load
            string notifyOption = (condition == NotifyCondition.OnlyIfJobFails ? "On error" : "This job");

            _controlPanel.Press(notifyOption);
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Pacekeeper.Sync();

            // On some devices (digital senders) this widget doesn't exist, since only email is available
            WidgetCollection widgets     = _controlPanel.GetWidgets();
            Widget           emailWidget = widgets.Find("E-mail");

            if (emailWidget != null)
            {
                _controlPanel.Press(emailWidget);
                Pacekeeper.Sync();
            }

            // Enter the email address
            Widget label          = widgets.Find("E-mail Address", StringMatch.StartsWith);
            Widget emailStringBox = widgets.FindByLabel(label, WidgetType.StringBox);

            _controlPanel.Press(emailStringBox);
            Pacekeeper.Sync();
            _controlPanel.PressKey(OzHardKey.Clear);
            _controlPanel.TypeOnVirtualKeyboard(address);
            Pacekeeper.Sync();
            _controlPanel.Press("OK");
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Pacekeeper.Sync();
            _controlPanel.Press("OK");
            Pacekeeper.Sync();
        }