예제 #1
0
        public static async Task <MockAgent> CreateAsync(string agentName, WalletConfiguration configuration, WalletCredentials credentials, ServiceCollection services, string issuerSeed = null, bool useMessageTypesHttps = false)
        {
            var provider = services.BuildServiceProvider();

            await provider.GetService <IProvisioningService>()
            .ProvisionAgentAsync(new AgentOptions
            {
                EndpointUri          = $"http://{agentName}",
                IssuerKeySeed        = issuerSeed,
                WalletConfiguration  = configuration,
                WalletCredentials    = credentials,
                UseMessageTypesHttps = useMessageTypesHttps
            });

            return(new MockAgent(agentName, provider)
            {
                Context = new DefaultAgentContext
                {
                    Wallet = await provider.GetService <IWalletService>().GetWalletAsync(configuration, credentials),
                    Pool = new PoolAwaitable(PoolUtils.GetPoolAsync),
                    SupportedMessages = AgentUtils.GetDefaultMessageTypes(),
                    UseMessageTypesHttps = useMessageTypesHttps
                },
                ServiceProvider = provider
            });
        }
예제 #2
0
        /// <summary>
        /// Checks if the window can be minimized
        /// </summary>
        /// <param name="fgHandle">window handle</param>
        /// <returns>true if it can</returns>
        private bool isWindowMinimizable(IntPtr fgHandle)
        {
            if (fgHandle == IntPtr.Zero)
            {
                return(false);
            }

            var window = AutomationElement.FromHandle(fgHandle);

            if (!Windows.IsApplicationFrameHostProcessWindow(fgHandle))
            {
                object objPattern;
                Log.Debug("controltype: " + window.Current.ControlType.ProgrammaticName);

                bool retVal = false;
                if (window.TryGetCurrentPattern(WindowPattern.Pattern, out objPattern))
                {
                    var windowPattern = objPattern as WindowPattern;
                    retVal = (windowPattern.Current.CanMinimize) && !windowPattern.Current.IsModal;

                    Log.Debug("canminimize: " + windowPattern.Current.CanMinimize + ", ismodal: " + windowPattern.Current.IsModal);
                }

                return(retVal);
            }

            var titleBar = findTitleBar(window);

            if (titleBar == null)
            {
                return(false);
            }

            return(AgentUtils.FindElementByAutomationId(titleBar, "", ControlType.Button, "Minimize") != null);
        }
예제 #3
0
 /// <summary>
 /// Invoked on a key up
 /// </summary>
 /// <param name="keyEventArgs">event arg</param>
 public override void OnKeyUp(KeyEventArgs keyEventArgs)
 {
     if (AgentUtils.IsPrintable(keyEventArgs.KeyCode))
     {
         triggerTextChanged(this);
     }
 }
예제 #4
0
        /// <summary>
        /// Is the active window an open Appointment window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <param name="subType">The focused Outlook window control element </param>
        /// <returns>true if it is</returns>
        public bool IsOpenAppointmentWindow(WindowActivityMonitorInfo monitorInfo, ref OutlookControlSubType subType)
        {
            Log.Debug();

            subType = OutlookControlSubType.Unknown;

            bool retVal = true;

            if (monitorInfo.FocusedElement == null)
            {
                return(false);
            }

            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);
            var element       = AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.ComboBox, "4098", "Start Date:") ??
                                AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4100", "Subject:");

            retVal = (element != null);

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Edit", "4100", "Subject:"))
                {
                    subType = OutlookControlSubType.AppointmentSubjectField;
                }
                else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "_WwG", "ControlType.Pane", "", "Message"))
                {
                    subType = OutlookControlSubType.AppointmentMessageBodyField;
                }
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
예제 #5
0
        /// <summary>
        /// Is the active window an open "Contact" window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <param name="subType">The focused Outlook window control element </param>
        /// <returns>true if it is</returns>
        public bool IsOpenContactWindow(WindowActivityMonitorInfo monitorInfo, ref OutlookControlSubType subType)
        {
            Log.Debug();

            subType = OutlookControlSubType.Unknown;

            bool retVal = true;

            if (monitorInfo.FocusedElement == null)
            {
                return(false);
            }

            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);
            var element       = (AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4481", "Company:") ??
                                 AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4480", "Job Title:")) ??
                                AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4096", "FullName");

            retVal = (element != null);

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "_WwG", "ControlType.Pane", "", "Message"))
                {
                    subType = OutlookControlSubType.ContactMessageField;
                }
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
예제 #6
0
파일: IE8Elements.cs 프로젝트: angellcq/src
 /// <summary>
 /// Is the focused element the search textbox?
 /// </summary>
 /// <param name="focusedElement">The control in focus</param>
 /// <returns>true if it is</returns>
 public bool IsSearchControl(AutomationElement focusedElement)
 {
     return(focusedElement != null &&
            String.Compare(focusedElement.Current.ClassName, "Edit", true) == 0 &&
            String.Compare(focusedElement.Current.ControlType.ProgrammaticName, "ControlType.Edit", true) == 0 &&
            AgentUtils.IsAncestorByName(focusedElement, "Search Control", "ControlType.Pane", ""));
 }
예제 #7
0
 /// <summary>
 /// Checks if the specified element is the message body field
 /// </summary>
 /// <param name="element">the automation element</param>
 /// <returns>true if it is</returns>
 protected bool isMessageBodyField(AutomationElement element)
 {
     return(AgentUtils.IsElementOrAncestorByAutomationId(element,
                                                         "EudoraEdit",
                                                         "ControlType.Pane",
                                                         "59664"));
 }
예제 #8
0
 /// <summary>
 /// Checks if the specified element is the TO field
 /// </summary>
 /// <param name="element">the automation element</param>
 /// <returns>true if it is</returns>
 protected bool isToField(AutomationElement element)
 {
     return(AgentUtils.IsElementOrAncestorByAutomationId(element,
                                                         "Edit",
                                                         "ControlType.Document",
                                                         "5050"));
 }
예제 #9
0
        public async Task InitializeAsync()
        {
            _issuerWallet = await AgentUtils.Create(IssuerConfig, WalletCredentials, true);

            _holderWallet = await AgentUtils.Create(HolderConfig, WalletCredentials, true);

            _requestorWallet = await AgentUtils.Create(RequestorConfig, WalletCredentials, true);
        }
예제 #10
0
        public async Task InitializeAsync()
        {
            _issuerWallet = await AgentUtils.Create(_issuerConfig, Credentials);

            _holderWallet = await AgentUtils.Create(_holderConfig, Credentials);

            _holderWalletTwo = await AgentUtils.Create(_holderConfigTwo, Credentials);
        }
예제 #11
0
    void Start()
    {
        agentController = GetComponent <AgentController>();
        utils           = GetComponent <AgentUtils>();
        config          = agentController.config;

        ball = GameObject.Find("Ball").transform;
    }
예제 #12
0
        /// <summary>
        /// Is the active window the email inbox window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsInboxWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "SuperGrid", ControlType.Table, "4704");

            return(element != null);
        }
예제 #13
0
    void UpdateReproductiveMultiplier()
    {
        ReproductiveClock += Time.deltaTime;

        if (ReproductiveClock <= AgentsSharedParameters.ReproductiveRecoveryTime)
        {
            ReproductiveMultiplier = AgentUtils.Remap(ReproductiveClock, 0f, AgentsSharedParameters.ReproductiveRecoveryTime, 0f, 1f);
        }
    }
예제 #14
0
        /// <summary>
        /// Checks if the specified element representing the Eudora
        /// window is the Browse email window
        /// </summary>
        /// <param name="element">the automation element</param>
        /// <returns>true if it is</returns>
        protected bool isBrowseEmailWindow(AutomationElement element)
        {
            Log.Debug();
            bool retVal = element != null &&
                          (AgentUtils.IsElementOrAncestor(element, "Internet Explorer_Server", "ControlType.Pane") ||
                           AgentUtils.IsElementOrAncestor(element, "EudoraEdit", "ControlType.Pane"));

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
예제 #15
0
        /// <summary>
        /// Is the active window the details window that is
        /// displayed when the user clicks on a name in the
        /// address book search results
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsAddressBookDetailsWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2002", R.GetString2("Outlook2010AddrBookFirstNameFieldLabel")) ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2006", R.GetString2("Outlook2010AddrBookLastNameFieldLabel")) ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Button", "ControlType.Button", "108", R.GetString2("Outlook2010AddrBookAddToContactsButtonText"));

            return(element != null);
        }
예제 #16
0
        /// <summary>
        /// Attaches a file to the current email being composed.  The currently
        /// focused window has to be the mail compose window.  Sends a
        /// Ctrl+H command to.  Launches the file browser to get the file to attach
        /// from the user.  Then inserts the filename into the attachment field
        /// in the mail compose window
        /// </summary>
        protected async void attachFile()
        {
            var info = WindowActivityMonitor.GetForegroundWindowInfo();

            if (!isMailComposeMessageWindow(info.FocusedElement) &&
                !isMailComposeWindow(info.FocusedElement))
            {
                Log.Debug("Wrong window");
                return;
            }

            _fileAttachment = String.Empty;
            await getFileToAttach();

            if (String.IsNullOrEmpty(_fileAttachment))
            {
                return;
            }

            Thread.Sleep(500);
            EnumWindows.RestoreFocusToTopWindow();
            Thread.Sleep(500);

            SendKeys.SendWait("^h");
            Thread.Sleep(1000);

            for (int ii = 0; ii < 10; ii++)
            {
                var info1 = WindowActivityMonitor.GetForegroundWindowInfo();
                if (info1.Title == "Attach File")
                {
                    Log.Debug("YES!  Found Attach file window");
                    var automationElement = AgentUtils.GetElementOrAncestorByAutomationId(
                        info1.FocusedElement,
                        "Edit",
                        "ControlType.Edit",
                        "1148");
                    if (automationElement != null)
                    {
                        Log.Debug("element is not null");
                        AgentUtils.InsertTextIntoElement(automationElement, _fileAttachment);
                        SendKeys.Send("{ENTER}");
                    }
                    else
                    {
                        Log.Debug("element is null");
                    }

                    break;
                }

                Thread.Sleep(500);
            }
        }
예제 #17
0
        /// <summary>
        /// Is the active window the details window that is
        /// displayed when the user clicks on a name in the
        /// address book search results
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsAddressBookDetailsWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2002", "First:") ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Edit", "ControlType.Edit", "2006", "Last:") ??
                          AgentUtils.FindElementByAutomationId(windowElement, "Button", "ControlType.Button", "108", "Add to Contacts");


            return(element != null);
        }
예제 #18
0
        /// <summary>
        /// Checks if the specified element representing the Eudora
        /// window is the Inbox
        /// </summary>
        /// <param name="element">the automation element</param>
        /// <returns>true if it is</returns>
        protected bool isInboxWindow(AutomationElement element)
        {
            Log.Debug();
            bool retVal = element != null &&
                          AgentUtils.IsAncestorByAutomationId(element,
                                                              "ListBox",
                                                              "ControlType.List",
                                                              "1159");

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
예제 #19
0
        /// <summary>
        /// Checks if the specified element representing the Eudora
        /// window is the mail composition window
        /// </summary>
        /// <param name="element">the automation element</param>
        /// <returns>true if it is</returns>
        protected bool isMailComposeMessageWindow(AutomationElement element)
        {
            Log.Debug();
            bool retVal = element != null &&
                          AgentUtils.IsElementOrAncestorByAutomationId(element,
                                                                       "EudoraEdit",
                                                                       "ControlType.Pane",
                                                                       "59664");

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
예제 #20
0
        /// <summary>
        /// Is the focused element the Address textbox?
        /// </summary>
        /// <param name="focusedElement">The control in focus</param>
        /// <returns>true if it is</returns>
        public bool IsAddressWindow(AutomationElement focusedElement)
        {
            var retVal = focusedElement != null &&
                         String.Compare(focusedElement.Current.ClassName, "Edit", true) == 0 &&
                         String.Compare(focusedElement.Current.ControlType.ProgrammaticName, "ControlType.Edit", true) == 0;

            if (retVal)
            {
                retVal = AgentUtils.IsAncestorByAutomationId(focusedElement, "Address Band Root", "ControlType.Pane", "41477");
            }

            return(retVal);
        }
예제 #21
0
    void Update()
    {
        if (JustBorn)
        {
            InitializeNewBorn();
        }

        MostUrgentNeedByIndex = NeedsManager.FindMostUrgentNeed(this);

        StateMachineRef.Execute();
        // Set Horn Color To State Color
        AgentUtils.SetChildColor(gameObject, 0, StateMachineRef.currentState.StateColor);
    }
예제 #22
0
    void Awake()
    {
        SetReferences();

        // Set body color
        AgentUtils.SetChildColor(gameObject, 2, AgentColor);

        InitializeTraits();

        InitializePathfinder();

        InitializeStateMachine();
    }
예제 #23
0
        /// <summary>
        /// Is the active window the Outlook calendar window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsCalendarWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "AfxWndW", ControlType.Text, "");

            if (element != null)
            {
                Log.Debug(element.Current.Name);
                return(element.Current.Name.ToLower().StartsWith(R.GetString2("Outlook2010TitleCalendarPrefix").ToLower()));
            }

            return(false);
        }
예제 #24
0
        /// <summary>
        /// Is the active window the Outlook calendar window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <returns>true if it is</returns>
        public bool IsCalendarWindow(WindowActivityMonitorInfo monitorInfo)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var element = AgentUtils.FindElementByAutomationId(windowElement, "AfxWndW", ControlType.Text, "");

            if (element != null)
            {
                Log.Debug("&&&&&& " + element.Current.Name);
                return(element.Current.Name.StartsWith("Calendar "));
            }

            return(false);
        }
예제 #25
0
        /// <summary>
        /// Attaches a file to the current email being composed.
        /// Launches the file browser to get the file to attach  from the user.
        /// Sends a command to bring up the Outlook "Insert File" dialog.
        /// Inserts the filename into the file name field in the dialog
        /// </summary>
        protected async void attachFile()
        {
            _fileAttachment = String.Empty;
            await getFileToAttach();

            if (String.IsNullOrEmpty(_fileAttachment))
            {
                return;
            }

            Thread.Sleep(500);
            EnumWindows.RestoreFocusToTopWindowOnDesktop();
            Thread.Sleep(500);

            AgentManager.Instance.Keyboard.Send(Keys.F10);
            AgentManager.Instance.Keyboard.Send(Keys.H);
            AgentManager.Instance.Keyboard.Send(Keys.A);
            AgentManager.Instance.Keyboard.Send(Keys.F);

            Thread.Sleep(1000);

            for (int ii = 0; ii < 10; ii++)
            {
                var info1 = WindowActivityMonitor.GetForegroundWindowInfo();
                if (String.Compare(info1.Title, R.GetString2("OutlookAttachFileWindowTitle"), true) == 0)
                {
                    Log.Debug("YES!  Found Attach file window");
                    var automationElement = AgentUtils.GetElementOrAncestorByAutomationId(
                        info1.FocusedElement,
                        "Edit",
                        "ControlType.Edit",
                        "1148");
                    if (automationElement != null)
                    {
                        Log.Debug("element is not null");
                        AgentUtils.InsertTextIntoElement(automationElement, _fileAttachment);
                        SendKeys.Send("{ENTER}");
                    }
                    else
                    {
                        Log.Debug("element is null");
                    }

                    break;
                }

                Thread.Sleep(500);
            }
        }
예제 #26
0
        /// <summary>
        /// Is the active window the Outlook Address book window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <param name="subType">The focused Outlook window control element </param>
        /// <returns>true if it is</returns>
        public bool IsAddressBookWindow(WindowActivityMonitorInfo monitorInfo, ref OutlookControlSubType subType)
        {
            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            var retVal = (windowElement != null) && (monitorInfo.Title.StartsWith("Address Book") &&
                                                     AgentUtils.IsElementByAutomationId(windowElement, "OutexABCLS",
                                                                                        "ControlType.Window", String.Empty));

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Edit", "101", "Search:"))
                {
                    subType = OutlookControlSubType.AddressBookSearchField;
                }
            }

            return(retVal);
        }
예제 #27
0
        /// <summary>
        /// Is the active window an open "Task" window?
        /// </summary>
        /// <param name="monitorInfo">Active window info</param>
        /// <param name="subType">The focused Outlook window control element </param>
        /// <returns>true if it is</returns>
        public bool IsOpenTaskWindow(WindowActivityMonitorInfo monitorInfo, ref OutlookControlSubType subType)
        {
            Log.Debug();

            subType = OutlookControlSubType.Unknown;

            bool retVal = true;

            if (monitorInfo.FocusedElement == null)
            {
                return(false);
            }

            var windowElement = AutomationElement.FromHandle(monitorInfo.FgHwnd);

            if (windowElement == null)
            {
                return(false);
            }

            var element = (AgentUtils.FindElementByAutomationId(windowElement, "REComboBox20W", ControlType.ComboBox, "4481", R.GetString2("Outlook2013OpenTaskStatusFieldLabel")) ??
                           AgentUtils.FindElementByAutomationId(windowElement, "REComboBox20W", ControlType.ComboBox, "4480", R.GetString2("Outlook2013OpenTaskPriorityFieldLabel"))) ??
                          AgentUtils.FindElementByAutomationId(windowElement, "RichEdit20WPT", ControlType.Edit, "4112", R.GetString2("Outlook2013OpenTaskPercentCompleteFieldLabel"));

            retVal = (element != null);

            if (retVal)
            {
                if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "RichEdit20WPT", "ControlType.Document", "4097"))
                {
                    subType = OutlookControlSubType.TaskSubjectField;
                }
                else if (AgentUtils.IsElementByAutomationId(monitorInfo.FocusedElement, "_WwG", "ControlType.Document", ""))
                {
                    subType = OutlookControlSubType.TaskMessageBodyField;
                }

                Log.Debug(subType.ToString());
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
예제 #28
0
    void Start()
    {
        agentController = GetComponent <AgentController>();
        utils           = GetComponent <AgentUtils>();
        config          = agentController.config;

        sideVector = utils.sideVector;
        ball       = GameObject.Find("Ball").transform;
        agentController.otherGoal.GetComponent <Goal>().scoreEvent.AddListener(AddPositiveReward);
        agentController.goal.GetComponent <Goal>().scoreEvent.AddListener(AddNegativeReward);

        fieldSize = utils.floor.lossyScale;

        currentTargetPosition = Vector3.zero;

        currentBallRegion = ball.position;

        RequestDecision();
    }
예제 #29
0
        /// <summary>
        /// Checks if the specified element representing the Eudora
        /// window is the mail compose window
        /// </summary>
        /// <param name="element">the automation element</param>
        /// <returns>true if it is</returns>
        protected bool isMailComposeWindow(AutomationElement element)
        {
            Log.Debug();
            bool retVal = element != null &&
                          AgentUtils.IsAncestorByAutomationId(element,
                                                              "AfxMDIFrame70",
                                                              "ControlType.Pane",
                                                              "59648");

            if (retVal)
            {
                Log.Debug("Checking if sibling is to fieild");
                retVal = AgentUtils.IsSiblingByAutomationId(element, "Edit", "ControlType.Document", "5050");
                Log.Debug("isSibling returned " + retVal);
            }

            Log.Debug("Returning " + retVal);
            return(retVal);
        }
예제 #30
0
    void InitializeNewBorn()
    {
        MaxAge            = Traits[0];
        ReproductiveUrge  = Traits[1];
        FoodConsumption   = Traits[2];
        EnergyConsumption = Traits[3];
        WorkingSpeed      = Traits[4];
        Size = Traits[5];

        // Apply Agent Body Color
        AgentUtils.SetChildColor(gameObject, 2, AgentColor);

        Energy = 90f;
        Food   = 20f;

        CurrentAge                      = 0f;
        ReproductiveMultiplier          = 0f;
        NeedsManager.NeedsValues[HORNY] = 0f;
        JustBorn = false;
    }