/// <summary>
        ///     Converts and EnnvironmentAgent to an IAddAgentViewModel.
        /// </summary>
        /// <param name="environmentAgent"></param>
        /// <returns></returns>
        public static IAgentManagementViewModel ToAddAgentViewModel(this EnvironmentAgent environmentAgent)
        {
            var agentManagementViewModel = new AgentManagementViewModel
            {
                SelectedEnvironment = environmentAgent.Environment,
                SelectedCountry     = new CountryInfo
                {
                    CountryCode = environmentAgent.AgentCountryIsoCode,
                    CountryName = environmentAgent.AgentCountry
                },
                SelectedCountrySubdivision = new SubdivisionInfo
                {
                    CountrySubdivisionCode = environmentAgent.AgentStateCode,
                    CountrySubdivisionName = environmentAgent.AgentState
                },
                AgentId          = environmentAgent.AgentId,
                AgentPos         = environmentAgent.AgentSequence,
                AgentPassword    = environmentAgent.AgentPassword,
                Language         = environmentAgent.Language,
                SelectedCurrency = environmentAgent.SendCurrencies?.Select(x => new CurrencyInfo {
                    CurrencyCode = x
                })
                                   .FirstOrDefault()
            };

            return(agentManagementViewModel);
        }
        /// <summary>
        ///     Edit Agent.
        /// </summary>
        /// <param name="agent"></param>
        public void EditAgent(EnvironmentAgent agent)
        {
            if (agent == null)
            {
                return;
            }

            SelectedEnvironment = agent.Environment;
            SelectedCountry     = CountryList?.Find(x => x.CountryCode == agent.AgentCountryIsoCode);

            var selectedSub = CountrySubdivisionList?.Find(x =>
                                                           x.CountrySubdivisionName != null && agent.AgentState != null &&
                                                           x.CountrySubdivisionName.ToUpper().Contains(agent.AgentState.ToUpper()));

            if (selectedSub != null && selectedSub.CountrySubdivisionCode.Contains("-"))
            {
                selectedSub.CountrySubdivisionCode = selectedSub.CountrySubdivisionCode.Split('-')[1];
            }
            SelectedCountrySubdivision = selectedSub;
            AgentId          = agent.AgentId;
            AgentPos         = agent.AgentSequence;
            AgentPassword    = agent.AgentPassword;
            Language         = agent.Language;
            SelectedCurrency = CurrencyList?.Find(x => x.CurrencyCode == agent.SendCurrencies?.First());
        }
 /// <summary>
 ///     Converts an EnvironmentAgent to an Agent.
 /// </summary>
 /// <param name="environmentAgent"></param>
 /// <param name="isTrainingMode"></param>
 /// <returns></returns>
 public static Agent ToAgent(this EnvironmentAgent environmentAgent, bool isTrainingMode)
 {
     return(new Agent
     {
         AgentId = environmentAgent.AgentId,
         AgentSequence = environmentAgent.AgentSequence,
         AgentPassword = environmentAgent.AgentPassword,
         Language = environmentAgent.Language,
         IsInTrainingMode = isTrainingMode
     });
 }
        /// <summary>
        ///     Delete Agent.
        /// </summary>
        public void DeleteAgent(EnvironmentAgent agent)
        {
            _settingsSvc.UserSettings.DeleteAgent(agent.Environment, agent.AgentId, agent.AgentSequence);
            _settingsSvc.Save();

            LoadEnvironments();
            RaisePropertyChanged(nameof(EnvironmentList));
            LoadAgents();
            RaisePropertyChanged(nameof(GroupedAgents));

            _messageBus.Publish(new AgentManagementChangedEvent());
        }
Exemple #5
0
 public void AddAgent(EnvironmentAgent agent)
 {
     if (EnvironmentAgents.ContainsKey(agent.Environment))
     {
         EnvironmentAgents[agent.Environment].Add(agent);
     }
     else
     {
         EnvironmentAgents.Add(agent.Environment, new List <EnvironmentAgent> {
             agent
         });
     }
 }
Exemple #6
0
        private void DrawAgent(EnvironmentAgent agent)
        {
            Gl.glColor3b(agent.Color.R, agent.Color.G, agent.Color.B);
            DrawCircle(agent.X, agent.Y, AgentWidth);

            Gl.glBegin(Gl.GL_LINE_LOOP);
            Gl.glVertex2d(agent.X, agent.Y);
            Gl.glVertex2d(agent.X + agent.Vector.X * AgentWidth, agent.Y + agent.Vector.Y * AgentWidth);
            Gl.glEnd();

            if (_isDebugMode)
            {
                Gl.glPushMatrix();
                drawBitmapText_(agent.Angle.ToString(), agent.X, agent.Y);
                Gl.glPopMatrix();
            }
        }
        /// <summary>
        ///     Converts an IAddAgentViewModel to an EnvironmentAgent.
        /// </summary>
        /// <param name="agentManagementViewModel"></param>
        /// <returns></returns>
        public static EnvironmentAgent ToEnvironmentAgent(this IAgentManagementViewModel agentManagementViewModel)
        {
            var environmentAgent = new EnvironmentAgent
            {
                Environment         = agentManagementViewModel.SelectedEnvironment,
                AgentCountryIsoCode = agentManagementViewModel.SelectedCountry?.CountryCode,
                AgentCountry        = agentManagementViewModel.SelectedCountry?.CountryName,
                AgentStateCode      = agentManagementViewModel.SelectedCountrySubdivision?.CountrySubdivisionCode,
                AgentState          = agentManagementViewModel.SelectedCountrySubdivision?.CountrySubdivisionName,
                AgentId             = agentManagementViewModel.AgentId,
                AgentSequence       = agentManagementViewModel.AgentPos,
                AgentPassword       = agentManagementViewModel.AgentPassword,
                Language            = agentManagementViewModel.Language,
                SendCurrencies      = new List <string> {
                    agentManagementViewModel.SelectedCurrency.CurrencyCode
                }
            };

            return(environmentAgent);
        }
Exemple #8
0
        public void UpdateAgent(EnvironmentAgent oldAgent, EnvironmentAgent newAgent)
        {
            var agent = GetAgent(oldAgent.Environment, oldAgent.AgentId, oldAgent.AgentSequence);

            if (agent == null)
            {
                return;
            }

            agent.Environment         = newAgent.Environment;
            agent.AgentCountryIsoCode = newAgent.AgentCountryIsoCode;
            agent.AgentCountry        = newAgent.AgentCountry;
            agent.AgentStateCode      = newAgent.AgentStateCode;
            agent.AgentState          = newAgent.AgentState;
            agent.AgentId             = newAgent.AgentId;
            agent.AgentSequence       = newAgent.AgentSequence;
            agent.AgentPassword       = newAgent.AgentPassword;
            agent.Language            = newAgent.Language;
            agent.SendCurrencies      = newAgent.SendCurrencies;
        }