public void Init(IHome View, bool IsPostBack) { _view = View; List <VisibilityLevel> _listVisibilityLevel = new List <VisibilityLevel>(); _listVisibilityLevel = _privacyService.GetListVisibilityLevel(); if (_userSession.LoggedIn == true) { IProfileRepository _profileRepository = new ProfileRepository(); Profile profile = _profileRepository.GetProfileByAccountID(_userSession.CurrentUser.AccountID); if (profile == null) { _redirector.Redirect("~/Profiles/ManageProfile.aspx"); } else { _view.LoadStatusControl(_listVisibilityLevel, true); account = _userSession.CurrentUser; if (!IsPostBack) { _view.LoadStatus(GetStatusToShow(account)); } } } else { account = null; _redirector.GoToAccountLoginPage(); } _view.DisplayCurrentAccount(account); }
/// <summary> /// Getting Header navigation menu along with logo details for the header /// </summary> /// <returns>Header details</returns> public IHeaderViewModel GetHeader() { IMvcContext mvcContext = _mvcContext(); //Checking the current item is the home item to display the Header based on this IHome contextItem = mvcContext.GetContextItem <IHome>(); _headerViewModel.SiteRoot = mvcContext.GetRootItem <ISiteRoot>(); if (contextItem.TemplateId.ToString().Equals(SitecoreSettings.HomeTemplateID, StringComparison.InvariantCultureIgnoreCase)) { _headerViewModel.SearchIcon = _sitecoreHelper.HomePageSearch; _headerViewModel.CloseIcon = _sitecoreHelper.HomePageClose; _headerViewModel.HeaderCss = CommonConstants.HomePageHeaderCss; _headerViewModel.IsHomePage = true; } else { _headerViewModel.SearchIcon = _sitecoreHelper.ContentPageSearch; _headerViewModel.CloseIcon = _sitecoreHelper.ContentPageClose; _headerViewModel.HeaderCss = CommonConstants.ContentPageHeaderCss; _headerViewModel.IsHomePage = false; } if (contextItem.TemplateId.ToString().Equals(SitecoreSettings.SearchPageTemplateID, StringComparison.InvariantCultureIgnoreCase)) { _headerViewModel.IsSearchPage = true; } else { _headerViewModel.IsSearchPage = false; } _headerViewModel.Header = _sitecoreHelper.NavigationHeader; return(_headerViewModel); }
void AttackEnemy(IHome myHome, IHome[] myHomes, IHome[] theirHomes) { List <IHome> enemyHomes = SortEnemyHomes(theirHomes); List <float> minusDistEnemies = new List <float>(); IHome choosenEnemyOne = null; foreach (var enemyHome in enemyHomes) { if (enemyHome.BoldiCount != 0 && Math.Abs(myHome.BoldiCount) / Math.Abs(enemyHome.BoldiCount) > 2 && enemyHome.BoldiCount < myHome.BoldiCount || enemyHome.BoldiCount == 0) { minusDistEnemies.Add(enemyHome.Position.magnitude); } } float[] arrayMinusEnemiesDist = minusDistEnemies.ToArray(); float minusEnemyDist = Mathf.Min(arrayMinusEnemiesDist); foreach (var enemyHome in enemyHomes) { if (minusEnemyDist == enemyHome.Position.magnitude) { choosenEnemyOne = enemyHome; } } if (myHomes.Length > 0 && theirHomes.Length > 0 && choosenEnemyOne != null) { LaunchBoldies(myHome, choosenEnemyOne, (EAmount.Half)); } }
/// <summary> /// Be conquerant spread everywhere in order to dominate the battle field /// </summary> void SpreadCuzItsFun() { // find a home which is mine IHome[] myHomes = m_Gameboard.GetHomes(TeamId, true); IHome[] theirHomes = m_Gameboard.GetHomes(TeamId, false); List <IHome> enemyHomes = SortEnemyHomes(theirHomes); foreach (IHome myHome in myHomes) { if (myHome.BoldiCount > 49) { foreach (IHome enemyHome in enemyHomes) { if (enemyHome.BoldiCount != 0 && myHome.BoldiCount / enemyHome.BoldiCount >= 2) { if (myHomes.Length > 0 && theirHomes.Length > 0) { IHome from = myHome; IHome to = enemyHome; EAmount amount = (EAmount.Half); LaunchBoldies(from, to, amount); } } } } } }
/// <summary> /// /// </summary> /// <param name="home"></param> /// <param name="formerTeamId"></param> public virtual void OnHomeChangedOwner(IHome home, int formerTeamId) { for (int i = 0; i < m_AliveAIs.Count; ++i) { m_AliveAIs[i].OnHomeChangedOwner(home, formerTeamId); } }
/// <summary> /// Called when an ai launches bodies (my self included) /// </summary> /// <param name="from"></param> /// <param name="to"></param> public void OnBoldiLaunch(IHome from, IHome to) { for (int i = 0; i < m_AliveAIs.Count; ++i) { m_AliveAIs[i].OnBoldiLaunch(from, to); } }
public ShellViewModel(IHome home, ISettings settings) { m_screens = new Dictionary <string, IScreen>(); m_screens.Add(nameof(IHome), home); m_screens.Add(nameof(ISettings), settings); Nav(nameof(IHome)); }
//public void NewNormalHome() //{ // CommunityViewModel.Instance.WriteLine("Making a new Home"); // var h = new BasicHome(new BasicPosition(50, 50)); // var vm = new BasicBuildingViewModel(h); // CommunityViewModel.Instance.Add(h); // NewBuildingCreated?.Invoke(this, vm); //} public void NewHome(IHome home) { CommunityViewModel.WriteLine("Adding a new Home"); CommunityViewModel.Add(home); NewBuildingCreated?.Invoke(this, home); }
public HomePresenter(IHome homeView, TipManagerModel tipManager, TipManagerServices services) { this.homeView = homeView; this.tipManager = tipManager; this.services = services; homeView.homeLoaded += new EventHandler(OnHomeLoaded); }
void LaunchSpread() { // find a home which is mine IHome[] myHomes = m_Gameboard.GetHomes(TeamId, true); IHome[] theirHomes = m_Gameboard.GetHomes(TeamId, false); List <IHome> neutralBoldiesPerHome = new List <IHome>(); List <IHome> enemiesBoldiesPerHome = new List <IHome>(); foreach (var myHome in myHomes) { foreach (var theirHome in theirHomes) { if (theirHome.TeamId == -1) { neutralBoldiesPerHome.Add(theirHome); } enemiesBoldiesPerHome.Add(theirHome); } foreach (var neutralBoldiesPerHom in neutralBoldiesPerHome) { if (neutralBoldiesPerHom.BoldiCount != 0 && myHome.BoldiCount / neutralBoldiesPerHom.BoldiCount >= 2 && myHome.BoldiCount > neutralBoldiesPerHom.BoldiCount || neutralBoldiesPerHom.BoldiCount == 0) { if (myHomes.Length > 0 && theirHomes.Length > 0) { IHome from = myHome; IHome to = neutralBoldiesPerHom; EAmount amount = (EAmount.ThreeQuarter); LaunchBoldies(from, to, amount); } } } foreach (var enemiesBoldiesPerHom in enemiesBoldiesPerHome) { if (enemiesBoldiesPerHom.BoldiCount != 0 && myHome.BoldiCount / enemiesBoldiesPerHom.BoldiCount >= 2 && myHome.BoldiCount > enemiesBoldiesPerHom.BoldiCount || enemiesBoldiesPerHom.BoldiCount == 0) { if (myHomes.Length > 0 && theirHomes.Length > 0) { IHome from = myHome; IHome to = enemiesBoldiesPerHom; EAmount amount = (EAmount.ThreeQuarter); LaunchBoldies(from, to, amount); } } } } }
private void GetPage(IHome data) { var page = MenuManager.Instance.GetItem() .OfType <IHome>() .FirstOrDefault(x => x.Page == data.Page && x.PageActive) ?.ClickArgument; _baseViewModel.GoPage(page); }
/// <summary> /// /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="amount"></param> protected void LaunchBoldies(IHome from, IHome to, EAmount amount) { // error control if (from == null) { XKLog.LogRed("Error", "AIBase.LaunchBodies() failed - (IHome)from is null"); return; } from.LaunchBoldies(to, amount, this); }
public TipManagerPresenter(ITipManager tipManagerView, IHome homeView, IAddTip addTipView, ITransaction transactionView) { this.tipManagerView = tipManagerView; this.homeView = homeView; this.addTipView = addTipView; this.transactionView = transactionView; tipManagerView.addTipButtonClicked += new EventHandler(OnAddTipButtonClicked); tipManagerView.homeButtonClicked += new EventHandler(OnHomeButtonClicked); tipManagerView.transactionButtonClicked += new EventHandler(OnTransactionButtonClicked); }
public void Init(IHome View) { _view = View; if(_userSession.LoggedIn==true) { account=_userSession.CurrentUser; } else account=null; _view.DisplayCurrentAccount(account); }
/// <summary> /// Opens the open form. /// </summary> /// <returns>Returns true or false depending on /// if the form opened successfully.</returns> public bool OpenHome() { try { m_home = new Home(this); //m_home.RegisterPresenter(this); m_home.OpenForm(); } catch (Exception) { return(false); } return(true); }
void LaunchRandom() { // find a home which is mine IHome[] myHomes = m_Gameboard.GetHomes(TeamId, true); IHome[] theirHomes = m_Gameboard.GetHomes(TeamId, false); // launch boldies if (myHomes.Length > 0 && theirHomes.Length > 0) { IHome from = myHomes[Lehmer.Range(0, myHomes.Length)]; IHome to = theirHomes[Lehmer.Range(0, theirHomes.Length)]; EAmount amount = (EAmount)Lehmer.Range(0, (int)EAmount.Count); LaunchBoldies(from, to, amount); } }
/// <summary> /// /// </summary> /// <param name="from"></param> /// <param name="to"></param> public override void OnBoldiLaunch(IHome from, IHome to) { base.OnBoldiLaunch(from, to); // don't care, I'm the one that launched the boldies if (from.TeamId == TeamId) { return; } // don't care, I'm not the target, though it may be a great idea to strike back at the offender if (to.TeamId != TeamId) { return; } }
static void Main(string[] args) { IHome home = null; //string sAttr; //sAttr = ConfigurationManager.AppSettings.Get("CASSANDRA_SERVER_NAME"); //Console.WriteLine(sAttr); using (var scope = DependencyResolver.Instance().BeginLifetimeScope()) { home = scope.Resolve <IHome>(); } //DBController db = new DBController(); //db.CheckCycle(Helper.SafeGuidParse("6ca697e6-8aa3-4536-8dc0-2ff6a68780ea"), Helper.SafeGuidParse("789cdd37-ecbc-4007-a059-55b2670b72f6")); //Console.WriteLine("Hello World\nHI"); home.ShowMainMenu(); }
/// <summary> /// Конструктор /// </summary> public HomeForm(IHome home, IStreets streets, IComplexes complexes, IDistricts districts) { InitializeComponent(); // Инициализировать компоненты формы _home = home; // Сохранить дом в поле _streets = streets; // Сохранить список улиц в поле _complexes = complexes; // Сохранить список комплексов в поле _districts = districts; _streetAfterRelinking = home.Street; // Сохранить улицу, связанную с домом в поле _complexAfterRelinking = home.Complex; // Сохранить комплекс, связанный с домом в поле _districtAfterRelinking = home.District; // Сохранить район, связанную с домом в поле CleanAllData(); // Очистить все данные формы CleanLocationData(); // Очистить данные характеристик дома CopyDataFromEntity(); // Скопировать данные из сущности в компоненты формы }
public NodeViewController(string balkKleur, IHome _home) : base("NodeViewController", null) { this._home = _home; if (!string.IsNullOrEmpty(balkKleur) && balkKleur.StartsWith("#")) { float red, green, blue; var colorString = balkKleur.Replace ("#", ""); red = Convert.ToInt32(string.Format("{0}", colorString.Substring(0, 2)), 16) / 255f; green = Convert.ToInt32(string.Format("{0}", colorString.Substring(2, 2)), 16) / 255f; blue = Convert.ToInt32(string.Format("{0}", colorString.Substring(4, 2)), 16) / 255f; _balkKleur = UIColor.FromRGBA(red, green, blue, 1.0f); } else { // Defaultkleur _balkKleur = UIColor.FromRGB(143, 202, 232); } _nodes = new List<BaseNode>(); }
/// <summary> /// Метод. Выбирает дом из списка домов, сохраняет в поле и закрывает диалоговое окно /// </summary> private void selectButton_Click(object sender, EventArgs e) { DataGridViewRow selectedRow; // Выделенная строка int id; // Идентификатор выделенного дома int rowCount; // Общее количество строк в списке int selectedRowIndex; // Индекс выделенной строки rowCount = entitiesDataGridView.Rows.Count; // Получить общее количество строк в списке if (rowCount > 0) // Проверить общее количество строк { selectedRow = entitiesDataGridView.SelectedRows[0]; // Получить выделенную строку selectedRowIndex = selectedRow.Index; // Получить индекс выделенной строки id = Convert.ToInt32(selectedRow.Cells["id"].Value); // Получить идентификатор дома в выделенной строке _selectedHome = _homes.GetHome(id); // Получить выделенный дома } CloseForm(); // Закрыть диалоговое окно }
private void OpenEdit(string t) { try { EditUserGamesViewModel viewModel = new EditUserGamesViewModel(); if (t.Equals("Add")) { viewModel.AddViewModel(); } else { viewModel.UpdateViewModel(HotGames); viewModel.Display = "UpdateViewModel"; } var dialog = ServiceProvider.Instance.Get <IModelDialog>("EditUserGamesDlg"); dialog.BindViewModel(viewModel); var d = Dialog.Show(dialog.GetDialog()); viewModel.ShowList += (async() => { d.Close(); HotGames.Clear(); IHome home = BridgeFactory.BridgeManager.GetHomeManager(); var comkmogenrator = await home.GetCommonUseGames(); if (comkmogenrator.code.Equals("000")) { var Results = JsonConvert.DeserializeObject <List <GetCommonUseGamesEntity> >(comkmogenrator.result.ToString()); if (Results != null && Results.Count != 0) { Results.ToList().ForEach((ary) => HotGames.Add(ary)); } } }); } catch (Exception ex) { Msg.Error(ex); } }
public NodeViewController(string balkKleur, IHome _home) : base("NodeViewController", null) { this._home = _home; if (!string.IsNullOrEmpty(balkKleur) && balkKleur.StartsWith("#")) { float red, green, blue; var colorString = balkKleur.Replace("#", ""); red = Convert.ToInt32(string.Format("{0}", colorString.Substring(0, 2)), 16) / 255f; green = Convert.ToInt32(string.Format("{0}", colorString.Substring(2, 2)), 16) / 255f; blue = Convert.ToInt32(string.Format("{0}", colorString.Substring(4, 2)), 16) / 255f; _balkKleur = UIColor.FromRGBA(red, green, blue, 1.0f); } else { // Defaultkleur _balkKleur = UIColor.FromRGB(143, 202, 232); } _nodes = new List <BaseNode>(); }
/// <summary> /// Get the the less powerfull team and attack it /// </summary> /// <param name="theirHomes"></param> /// <param name="myHome"></param> void AttackTheLessPowerful(IHome[] theirHomes, IHome myHome) { int temp = 10000; int lessPowerful = 0; List <IHome> enemyHomes = SortEnemyHomes(theirHomes); List <int> EnemyTeamIdHome = new List <int>(); foreach (IHome enemyHome in enemyHomes) { EnemyTeamIdHome.Add(enemyHome.TeamId); } List <int> disinctHome = EnemyTeamIdHome.Distinct().ToList(); foreach (int home in disinctHome) { foreach (IHome enemyHome in enemyHomes) { if (enemyHome.TeamId == home) { if (enemyHome.BoldiCount < temp) { temp = enemyHome.BoldiCount; lessPowerful = enemyHome.TeamId; } } } } foreach (IHome enemyHome in enemyHomes) { if (enemyHome.TeamId == lessPowerful) { LaunchBoldies(myHome, enemyHome, (EAmount.Half)); } } }
/// <summary> /// 移除 /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="model"></param> public override async void Del <TModel>(TModel model) { try { DisplayMetro = System.Windows.Visibility.Visible; var selectModel = HotGames.Where(s => s.IsSelected).ToList(); if (selectModel.Any()) { List <int> gameIds = new List <int>(); selectModel.ForEach((ary) => gameIds.Add(ary.id)); IHome user = BridgeFactory.BridgeManager.GetHomeManager(); var genrator = await user.UpdateCommomUseGames(gameIds, "0"); if (genrator.code.Equals("000")) { ShowList?.Invoke(); } else { Msg.Info(genrator.Message); } } else { Msg.Info("请勾选您需要的游戏"); } } catch (Exception ex) { Msg.Error(ex); } finally { DisplayMetro = System.Windows.Visibility.Collapsed; } }
void AttackNeutral(IHome myHome, IHome[] myHomes, IHome[] theirHomes) { List <float> minusDistNeutral = new List <float>(); List <IHome> neutralHome = SortNeutralHomes(theirHomes); IHome choosenNeutralOne = null; foreach (var neutral in neutralHome) { if (neutral.BoldiCount <= 2) { LaunchBoldies(myHome, neutral, (EAmount.Quarter)); } else if (Math.Abs(myHome.BoldiCount) / Math.Abs(neutral.BoldiCount) > 2 && neutral.BoldiCount < myHome.BoldiCount) { minusDistNeutral.Add(neutral.Position.magnitude); } } float[] arrayMinusNeutralDist = minusDistNeutral.ToArray(); float minustNeutralDist = Mathf.Min(arrayMinusNeutralDist); foreach (var neutral in neutralHome) { if (minustNeutralDist == neutral.Position.magnitude) { choosenNeutralOne = neutral; minusDistNeutral.Remove(neutral.Position.magnitude); } } if (myHomes.Length > 0 && theirHomes.Length > 0 && choosenNeutralOne != null) { LaunchBoldies(myHome, choosenNeutralOne, (EAmount.Half)); } }
public HomePresenter(IHome view, INavigationWorkflow navigation) { this._view = view; this._navigation = navigation; }
public HomeController() { service = new HomeService(); }
public HomeController() { this._repo = new HomeRepository(new JaverianaReservasContext()); }
bool IHome.LaunchBoldies(IHome to, EAmount amount, AIBase ai) { // error control if (TeamId < 0) { XKLog.Log("Error", "Home.LaunchBodies() failed - home does not belong to any team"); return(false); } // error control if (TeamId != ai.TeamId) { XKLog.LogRed("Error", "Home.LaunchBodies() failed - Wrong AI asked a move from unowned Home, are you such a cheater? - " + ai.GetType().ToString()); return(false); } // error control if (to == null) { XKLog.LogRed("Error", "Home.LaunchBodies() failed - (IHome)to is null"); return(false); } // avoid StackOverFlow exception if (!CanLaunchBoldies((Home)to)) { return(false); } // compute boldiCount to launch int boldiCount = m_BoldiCount; switch (amount) { case EAmount.Quarter: boldiCount = (int)(m_BoldiCount * 0.25f); break; case EAmount.Half: boldiCount = (int)(m_BoldiCount * 0.5f); break; case EAmount.ThreeQuarter: boldiCount = (int)(m_BoldiCount * 0.75f); break; } // launch them if (!m_ToLaunch.ContainsKey((Home)to)) { m_ToLaunch.Add((Home)to, boldiCount); } else { m_ToLaunch[(Home)to] += boldiCount; } // notify who wants to listen m_Gameboard.OnBoldiLaunch(this, to); return(true); }
public HomeController(IHome i) { o = i; }
public HomeController() { _homeAdapter = new HomeAdapter(); }
public HomeController(IHome home) { this.home = home; }
public HomeController() { homeBO = homeBO ?? new HomeBO(); }
public void Init(IHome View, bool IsPostBack) { _view = View; List<VisibilityLevel> _listVisibilityLevel = new List<VisibilityLevel>(); _listVisibilityLevel = _privacyService.GetListVisibilityLevel(); if (_userSession.LoggedIn == true) { IProfileRepository _profileRepository = new ProfileRepository(); Profile profile = _profileRepository.GetProfileByAccountID(_userSession.CurrentUser.AccountID); if (profile == null) _redirector.Redirect("~/Profiles/ManageProfile.aspx"); else { _view.LoadStatusControl(_listVisibilityLevel, true); account = _userSession.CurrentUser; if (!IsPostBack) { _view.LoadStatus(GetStatusToShow(account), GetAlertToShow(account)); } } } else { account = null; _redirector.GoToAccountLoginPage(); } _view.DisplayCurrentAccount(account); }
/// <summary> /// Статический метод. Преобразует объект типа IHome в объект типа Home /// </summary> public static Home IHomeToHomeConverter(IHome home) { return((Home)home); }
public HomeController(IHome<home> repository, IUser<user> userRepository, IAdmin<admin> adminRepository) { _userRepository = userRepository; _homeRepository = repository; _adminRepository = adminRepository; }
// // GET: /Admin/ public AdminController(IHome j) { i = j; }
public HomeController() { _homeRepository = new HomeRepository(); _userRepository = new UserRepository(); _adminRepository = new AdminRepository(); }
//GET: /<controller>/ //public IActionResult Index(string page) //{ // return View("Plain", page); //} public IActionResult Index(IHome page) { return(View("ViewModel", page)); }
public MenuViewController(IHome home) : base("MenuViewController", null) { _home = home; }