public async Task <IActionResult> PutUserScreen([FromRoute] string id, [FromBody] UserScreen userScreen) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userScreen.UserName) { return(BadRequest()); } _context.Entry(userScreen).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserScreenExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public override void Execute() { amount = PrompForDepositAmount(); if (amount != CANCELED) { UserScreen.DisplayMessage("\nPlease insert a deposit envelope containing"); UserScreen.DisplayDollaramount(amount); UserScreen.DisplayMessageLine("in the deposit slot"); bool envelopeReceived = depositSlot.isDepositEnvelopeReceived(); if (envelopeReceived) { UserScreen.DisplayMessageLine("Your envelope has been received"); Database.Credit(AccountNumber, amount); } else { UserScreen.DisplayMessageLine("you did not insert an envelope "); } } else { UserScreen.DisplayMessageLine("jwıjdwjd"); } }
public int displayMenu() { int choose = 0; int[] amount = { 20, 40, 60, 80 }; while (choose == 0) { UserScreen.DisplayMessage("Menu\n"); UserScreen.DisplayMessage("1.$20\n\n"); UserScreen.DisplayMessage("2.$40\n\n"); UserScreen.DisplayMessage("3.$60\n\n"); UserScreen.DisplayMessage("4.$80\n\n"); UserScreen.DisplayMessage("Choose a withdrawal amount"); int temp = keypad.GetInput(); switch (temp) { case 1: case 2: case 3: case 4: choose = amount[temp]; break; case 6: choose = CANCELED; break; default: UserScreen.DisplayMessage("Its not example. Please try again"); break; } } return(choose); }
public async Task <IActionResult> PostUserScreen([FromBody] UserScreen userScreen) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.UserScreen.Add(userScreen); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (UserScreenExists(userScreen.UserName)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetUserScreen", new { id = userScreen.UserName }, userScreen)); }
// perform transaction, overrides Transaction's abstract method public override void Execute() { bool cashDispensed = false; // cash was not dispensed yet // transaction was not canceled yet bool transactionCanceled = false; // loop until cash is dispensed or the user cancels do { // obtain the chosen withdrawal amount from the user int selection = DisplayMenuOfAmounts(); // check whether user chose a withdrawal amount or canceled if (selection != CANCELED) { // set amount to the selected dollar amount amount = selection; // get available balance of account involved decimal availableBalance = Database.GetAvailableBalance(AccountNumber); // check whether the user has enough money in the account if (amount <= availableBalance) { // check whether the cash dispenser has enough money if (cashDispenser.IsSufficientCashAvailable(amount)) { // debit the account to reflect the withdrawal Database.Debit(AccountNumber, amount); cashDispenser.DispenseCash(amount); // dispense cash cashDispensed = true; // cash was dispensed // instruct user to take cash UserScreen.DisplayMessageLine( "\nPlease take your cash from the cash dispenser."); } else // cash dispenser does not have enough cash { UserScreen.DisplayMessageLine( "\nInsufficient cash available in the ATM." + "\n\nPlease choose a smaller amount."); } } else // not enough money available in user's account { UserScreen.DisplayMessageLine( "\nInsufficient cash available in your account." + "\n\nPlease choose a smaller amount."); } } else { UserScreen.DisplayMessageLine("\nCanceling transaction..."); transactionCanceled = true; // user canceled the transaction } } while ((!cashDispensed) && (!transactionCanceled)); }
async private static void StartGame(string username, string password) { UserScreen screen = new UserScreen(); NetManager netManager = new NetManager(screen); netManager.Init(); if (loginState == LoginState.UNAVAILABLE) { loginMessage = "The server is unavailable."; loginState = LoginState.MENU; return; } string hashedPassword = Hash(password); netManager.Login(username, hashedPassword); loginMessage = "Logging in..."; loginState = LoginState.LOGGING_IN; for (int i = 0; i < 1000; i++) { await Task.Delay(10); if (loginState != LoginState.LOGGING_IN) { break; } } if (loginState == LoginState.LOGGING_IN) { loginState = LoginState.MENU; loginMessage = "Login Timeout"; } else if (loginState == LoginState.LOGGED) { loginMessage = ""; currentState = MenuState.LOGIN; screen.netManager = netManager; screen.username = username; GuiData.hot = -1; InPasswordMode = false; Hacknet.Gui.TextBox.MaskingText = false; Hacknet.Gui.TextBox.cursorPosition = 0; bMenu.ScreenManager.AddScreen(screen, new PlayerIndex?(bMenu.ScreenManager.controllingPlayer)); } else if (loginState == LoginState.INVALID) { loginMessage = "Invalid Username or Password."; } else if (loginState == LoginState.UNAVAILABLE) { loginMessage = "The server is unavailable."; } loginState = LoginState.MENU; ResetForLogin(); }
// islem yapilabiliyor mu private bool IsWithrawal(int val) { // cekebilecegin para var mi? if (val <= Database.getAvaibleBalance(AccountNumber)) { // ATM de para var mi if (cashDispenser.IsSufficiantCashAvaible(val)) { Database.Debit(AccountNumber, val); cashDispenser.DispenseCash(val); return(true); } else { UserScreen.DisplayMessageLine("ERROR: money in ATM is not enough!"); UserScreen.Sleep(3000); } } else { UserScreen.DisplayMessage("\nERROR: your avaible balance: "); UserScreen.DisplayDollarAmount(Database.getAvaibleBalance(AccountNumber)); UserScreen.Sleep(2000); } return(false); }
public OnNetTerminal(Rectangle location, UserScreen screen) : base(location, screen) { this.history = new System.Collections.Generic.List <string>(512); this.prompt = ""; this.currentLine = ""; Hacknet.Gui.TextBox.cursorPosition = 0; Hacknet.Gui.TextBox.textDrawOffsetPosition = 0; }
public OnModule(Rectangle location, UserScreen screen) { location.Y += OnModule.PANEL_HEIGHT; location.Height -= OnModule.PANEL_HEIGHT; this.bounds = location; this.userScreen = screen; this.spriteBatch = this.userScreen.ScreenManager.SpriteBatch; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); mousePos = e.Location; if (dragging) { var players = profile.PlayerData; PlayerInfo player = players[draggingIndex]; Rectangle p = player.EditBounds; if (draggingScreen == -1) { for (int i = 0; i < screens.Length; i++) { UserScreen screen = screens[i]; Rectangle s = screen.UIBounds; float pc = RectangleUtil.PcInside(p, s); // bigger than 60% = major part inside this screen if (pc > 0.6f) { float offset = s.Width * 0.05f; // check if there's space available on this screen var playas = profile.PlayerData; Rectangle?editor; Rectangle?monitor; GetFreeSpace(i, out editor, out monitor); if (editor != null) { draggingScreenRec = editor.Value; draggingScreenBounds = monitor.Value; draggingScreen = i; } break; } } } else { Rectangle s = screens[draggingScreen].UIBounds; float pc = RectangleUtil.PcInside(p, s); if (pc < 0.6f) { draggingScreen = -1; } } p = new Rectangle(mousePos.X + draggingOffset.X, mousePos.Y + draggingOffset.Y, p.Width, p.Height); players[draggingIndex].EditBounds = p; Invalidate(); } }
protected override void OnMouseDoubleClick(MouseEventArgs e) { base.OnMouseDoubleClick(e); if (dragging) { return; } if (e.Button == MouseButtons.Left) { // first count how many gamepads we have bool changed = false; for (int i = 0; i < screens.Length; i++) { UserScreen screen = screens[i]; if (screen.UIBounds.Contains(e.Location) && !screen.SwapTypeBounds.Contains(e.Location)) { List <PlayerInfo> playerData = profile.PlayerData; // add all possible players! for (int j = 0; j < playerData.Count; j++) { PlayerInfo player = playerData[j]; Rectangle?editor; Rectangle?monitor; bool hasFreeSpace = GetFreeSpace(i, out editor, out monitor); if (hasFreeSpace) { if (player.ScreenIndex == -1) { player.Owner = screens[i]; player.ScreenIndex = i; player.MonitorBounds = monitor.Value; player.EditBounds = editor.Value; changed = true; } } else { break; } } break; } } if (changed) { UpdatePlayers(); } } }
public TraceOverlay(SpriteBatch batch, Rectangle rect, UserScreen screen, float progress, float speed) : base(batch, rect, screen) { this.progress = progress; this.speed = speed; if (TraceOverlay.font == null) { TraceOverlay.font = screen.content.Load <SpriteFont>("Kremlin"); TraceOverlay.font.Spacing = 11f; } }
public override void Execute() { //get available balance for the current user's Account decimal availableBalance = Database.GetAvailableBalance(AccountNumber); decimal totalBalance = Database.GetTotalBalance(AccountNumber); UserScreen.DisplayMessage("Balance Information:"); UserScreen.appendMessage(" - Available balance: " + availableBalance); UserScreen.appendMessage(" - Total balance: " + totalBalance); UserScreen.appendMessage(""); }
public override void Execute() { decimal Balance = Database.getAvailableBalance(AccountNumber); decimal TotalBalance = Database.getTotalBalance(AccountNumber); UserScreen.DisplayMessageLine("Information: "); UserScreen.DisplayMessage("Available Balance: "); UserScreen.DisplayDollaramount(Balance); UserScreen.DisplayMessage("Total Balance"); UserScreen.DisplayDollaramount(TotalBalance); UserScreen.DisplayMessageLine(" "); }
// display a menu of withdrawal amounts and the option to cancel; // return the chosen amount or 6 if the user chooses to cancel private int DisplayMenuOfAmounts() { int userChoice = 0; // variable to store return value // array of amounts to correspond to menu numbers int[] amounts = { 0, 20, 40, 60, 100, 200 }; // loop while no valid choice has been made while (userChoice == 0) { // display the menu UserScreen.DisplayMessageLine("\nWithdrawal options:"); UserScreen.DisplayMessageLine("1 - $20"); UserScreen.DisplayMessageLine("2 - $40"); UserScreen.DisplayMessageLine("3 - $60"); UserScreen.DisplayMessageLine("4 - $100"); UserScreen.DisplayMessageLine("5 - $200"); UserScreen.DisplayMessageLine("6 - Cancel transaction"); UserScreen.DisplayMessage( "\nChoose a withdrawal option (1-6): "); // get user input through keypad int input = keypad.GetInput(); // determine how to proceed based on the input value switch (input) { // if the user chose a withdrawal amount (i.e., option // 1, 2, 3, 4, or 5), return the corresponding amount // from the amounts array case 1: case 2: case 3: case 4: case 5: userChoice = amounts[input]; // save user's choice break; case CANCELED: // the user chose to cancel userChoice = CANCELED; // save user's choice break; default: UserScreen.DisplayMessageLine( "\nInvalid selection. Try again."); break; } } return(userChoice); }
private decimal PrompForDepositAmount() { UserScreen.DisplayMessageLine("\n please input a deposit amount in Cents"); int input = keypad.GetInput(); if (input == CANCELED) { return(CANCELED); } else { return(input); } }
public override void Execute() { BankDatabase bankDatabase = database; var AvailableBalance = bankDatabase.getAvailableBalance(AccountNumber); var TotalBalance = bankDatabase.getTotalBalance(AccountNumber); UserScreen.DisplayMessageLine("\nBalance Information"); UserScreen.DisplayMessage(" - Available Balance: "); UserScreen.DisplayDollarAmount(AvailableBalance); UserScreen.DisplayMessage("\n - Total Balance: "); UserScreen.DisplayDollarAmount(TotalBalance); UserScreen.DisplayMessageLine(""); }
public void Should_List_User() { try { UserScreen = new UserScreen(); UserScreen.ShowScreen(); UserScreen.ValidateList(); } catch (Exception ex) { throw ErrorUtil.GetError(ex); } finally { UserScreen.CloseScreen(); } }
// yatirilacak parayi gir private decimal PromptForDepositAmount() { UserScreen.DisplayMessage( "\nEnter amount for deposit (or 0 to cancel): " ); int input = keypad.GetInput(); if (input == CANCELLED) { return(CANCELLED); } else { return(input); } }
// performs transaction; overrides Transaction's abstract method public override void Execute() { // get the available balance for the current user's Account decimal availableBalance = Database.GetAvailableBalance(AccountNumber); // get the total balance for the current user's Account decimal totalBalance = Database.GetTotalBalance(AccountNumber); // display the balance information on the screen UserScreen.DisplayMessageLine("\nBalance Information:"); UserScreen.DisplayMessage(" - Available balance: "); UserScreen.DisplayDollarAmount(availableBalance); UserScreen.DisplayMessage("\n - Total balance: "); UserScreen.DisplayDollarAmount(totalBalance); UserScreen.DisplayMessageLine(""); }
// prompt user to enter a deposit amount to credit private decimal PromptForDepositAmount() { // display the prompt and receive input UserScreen.DisplayMessage( "\nPlease input a deposit amount in CENTS (or 0 to cancel): "); int input = keypad.GetInput(); // check whether the user canceled or entered a valid amount if (input == CANCELED) { return(CANCELED); } else { return(input / 100.00M); } }
public TerminationOverlay(SpriteBatch batch, Rectangle displayRect, UserScreen screen) : base(batch, displayRect, screen) { fullscreen = this.displayRect; Random rnd = new Random(); float choice = (float)rnd.NextDouble(); this.spinDownSound = screen.content.Load <SoundEffect>("Music/Ambient/spiral_gauge_down"); foreach (KeyValuePair <float, string> message in farewellMessages) { if (message.Key > choice) { chosenStr = message.Value; break; } } }
private bool DisplayMenu() { UserScreen.Clear(); UserScreen.DisplayMessageLine("\nWithdrawal menu\n"); UserScreen.DisplayMessageLine("1->\t$10"); UserScreen.DisplayMessageLine("2->\t$20"); UserScreen.DisplayMessageLine("3->\t$50"); UserScreen.DisplayMessageLine("4->\t$100"); UserScreen.DisplayMessageLine("5->\t$200"); UserScreen.DisplayMessageLine("6->\t$500"); UserScreen.DisplayMessageLine("7->\t2000"); UserScreen.DisplayMessageLine("8->\tOther"); UserScreen.DisplayMessageLine("9->\tCancel transaction"); UserScreen.DisplayMessage("\nChoose a with drawal amount: "); switch (keypad.GetInput()) { case (int)Menu.AMOUNT10: return(IsWithrawal(10)); case (int)Menu.AMOUNT20: return(IsWithrawal(20)); case (int)Menu.AMOUNT50: return(IsWithrawal(50)); case (int)Menu.AMOUNT100: return(IsWithrawal(100)); case (int)Menu.AMOUNT200: return(IsWithrawal(200)); case (int)Menu.AMOUNT500: return(IsWithrawal(500)); case (int)Menu.AMOUNT2000: return(IsWithrawal(2000)); case (int)Menu.OTHER: UserScreen.DisplayMessage("\nEnter a value: "); return(IsWithrawal(keypad.GetInput())); case (int)Menu.GO_BACK: return(false); default: UserScreen.DisplayMessageLine("\nInvalid selection! Try again."); break; } return(false); }
public override void Execute() { amount = PromptForDepositAmount(); if (amount != CANCELLED) { // tek seferde yatirilabilecek miktar bool envelopeReceived = depositSlot.IsDepositEnvelopeReceived(amount); if (envelopeReceived) { UserScreen.DisplayMessageLine("\nAmount: " + amount); UserScreen.DisplayMessageLine("\nPress for 1 to cancel. Press enter for continue."); // yatirmak icin engel yok yatirmak icin onayla if (keypad.GetInput(true) != 1) { Database.Credit(AccountNumber, amount); UserScreen.DisplayMessageLine("\nDeposit operation success"); UserScreen.Sleep(4000); } else { UserScreen.DisplayMessageLine("\nOperation cancelled!"); UserScreen.Sleep(4000); } } else { UserScreen.DisplayMessageLine( "\nSlot is not enough. Operation cancelled!" ); UserScreen.Sleep(4000); } } else { UserScreen.DisplayMessageLine( "\nCancelling operation..." ); UserScreen.Sleep(4000); UserScreen.Sleep(2000); } }
// islem yap public override void Execute() { BankDatabase bankDatabase = Database; Screen screen = UserScreen; bool isContinue = true; while (isContinue) { bool display = DisplayMenu(); if (display == true) { UserScreen.DisplayMessageLine("\nOperation success!"); isContinue = DoYouWantToContinue(); } else if (display == false) { isContinue = false; } } }
/// <summary> /// Position the form on the same monitor the user has put our app! /// (by default, forms are open on the primary monitor, but if the user dragged /// our form to another monitor the child forms still get created on the main monitor. /// This is a small quality of life fix) /// </summary> /// <param name="f">The form to move</param> protected void SetUpForm() { UserScreen[] screens = ScreensUtil.AllScreens(); Point pos = Cursor.Position; Rectangle cursorScreen = Rectangle.Empty; for (int i = 0; i < screens.Length; i++) { UserScreen user = screens[i]; Rectangle bounds = user.MonitorBounds; if (bounds.Contains(pos)) { cursorScreen = bounds; break; } } this.SetDesktopLocation(cursorScreen.X + 100, cursorScreen.Y + 100); }
// perform transaction; overrides Transaction's abstract method public override void Execute() { amount = PromptForDepositAmount(); // get deposit amount from user // check whether user entered a deposit amount or canceled if (amount != CANCELED) { // request deposit envelope containing specified amount UserScreen.DisplayMessage( "\nPlease insert a deposit envelope containing "); UserScreen.DisplayDollarAmount(amount); UserScreen.DisplayMessageLine(" in the deposit slot."); // retrieve deposit envelope bool envelopeReceived = depositSlot.IsDepositEnvelopeReceived(); // check whether deposit envelope was received if (envelopeReceived) { UserScreen.DisplayMessageLine( "\nYour envelope has been received.\n" + "The money just deposited will not be available " + "until we \nverify the amount of any " + "enclosed cash, and any enclosed checks clear."); // credit account to reflect the deposit Database.Credit(AccountNumber, amount); } else { UserScreen.DisplayMessageLine( "\nYou did not insert an envelope, so the ATM has " + "canceled your transaction."); } } else { UserScreen.DisplayMessageLine("\nCanceling transaction..."); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); var players = profile.PlayerData; if (dragging) { return; } if (e.Button == MouseButtons.Left) { for (int i = 0; i < screens.Length; i++) { UserScreen screen = screens[i]; if (screen.SwapTypeBounds.Contains(e.Location)) { if (screen.Type == UserScreenType.SixteenPlayers) { screen.Type = 0; } else { screen.Type++; } // invalidate all players inside screen for (int j = 0; j < players.Count; j++) { // return to default position PlayerInfo p = players[j]; if (p.ScreenIndex == i) { p.EditBounds = GetDefaultBounds(j); p.ScreenIndex = -1; } } Invalidate(); return; } } for (int i = 0; i < players.Count; i++) { Rectangle r = players[i].EditBounds; if (r.Contains(e.Location)) { dragging = true; draggingIndex = i; draggingOffset = new Point(r.X - e.X, r.Y - e.Y); Rectangle newBounds = GetDefaultBounds(draggingIndex); profile.PlayerData[draggingIndex].EditBounds = newBounds; if (draggingOffset.X < -newBounds.Width || draggingOffset.Y < -newBounds.Height) { draggingOffset = new Point(0, 0); } break; } } } else if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Middle) { // if over a player on a screen, change the type for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; Rectangle r = p.EditBounds; if (r.Contains(e.Location)) { if (p.ScreenIndex != -1) { UserScreen screen = screens[p.ScreenIndex]; int halfWidth = screen.MonitorBounds.Width / 2; int halfHeight = screen.MonitorBounds.Height / 2; Rectangle bounds = p.MonitorBounds; if (screen.Type == UserScreenType.FourPlayers) { // check if the size is 1/4th of screen if (bounds.Width == halfWidth && bounds.Height == halfHeight) { bool hasLeftRightSpace = true; bool hasTopBottomSpace = true; // check if we have something left/right or top/bottom for (int j = 0; j < players.Count; j++) { if (i == j) { continue; } PlayerInfo other = players[j]; if (other.ScreenIndex != p.ScreenIndex) { continue; } if (other.MonitorBounds.Y == p.MonitorBounds.Y) { hasLeftRightSpace = false; } if (other.MonitorBounds.X == p.MonitorBounds.X) { hasTopBottomSpace = false; } if (other.MonitorBounds.X == screen.MonitorBounds.X + halfWidth && other.MonitorBounds.Height == screen.MonitorBounds.Height) { hasLeftRightSpace = false; } if (other.MonitorBounds.X == screen.MonitorBounds.X && other.MonitorBounds.Width == screen.MonitorBounds.Width) { hasTopBottomSpace = false; } } if (hasLeftRightSpace) { Rectangle edit = p.EditBounds; if (bounds.X == screen.MonitorBounds.X + bounds.Width) { bounds.X -= bounds.Width; edit.X -= edit.Width; } bounds.Width *= 2; edit.Width *= 2; p.EditBounds = edit; p.MonitorBounds = bounds; Invalidate(); } else if (hasTopBottomSpace) { bounds.Height *= 2; p.MonitorBounds = bounds; Rectangle edit = p.EditBounds; edit.Height *= 2; p.EditBounds = edit; Invalidate(); } } else { bounds.Width = screen.MonitorBounds.Width / 2; bounds.Height = screen.MonitorBounds.Height / 2; p.MonitorBounds = bounds; Rectangle edit = p.EditBounds; edit.Width = screen.UIBounds.Width / 2; edit.Height = screen.UIBounds.Height / 2; p.EditBounds = edit; Invalidate(); } } } } } } }
private bool GetFreeSpace(int screenIndex, out Rectangle?editorBounds, out Rectangle?monitorBounds) { editorBounds = null; monitorBounds = null; var players = profile.PlayerData; UserScreen screen = screens[screenIndex]; Rectangle bounds = screen.MonitorBounds; Rectangle ebounds = screen.UIBounds; switch (screen.Type) { case UserScreenType.FullScreen: for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; if (p.ScreenIndex == screenIndex) { return(false); } } monitorBounds = screen.MonitorBounds; editorBounds = screen.UIBounds; return(true); case UserScreenType.DualHorizontal: { int playersUsing = 0; Rectangle areaUsed = new Rectangle(); for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; if (p.ScreenIndex == screenIndex) { playersUsing++; areaUsed = p.MonitorBounds; } } if (playersUsing == 2) { return(false); } int half = (int)(bounds.Height / 2.0f); for (int i = 0; i < 2; i++) { Rectangle area = new Rectangle(bounds.X, bounds.Y + (half * i), bounds.Width, half); if (!areaUsed.Contains(area)) { monitorBounds = area; int halfe = (int)(ebounds.Height / 2.0f); editorBounds = new Rectangle(ebounds.X, ebounds.Y + (halfe * i), ebounds.Width, halfe); return(true); } } } break; case UserScreenType.DualVertical: { int playersUsing = 0; Rectangle areaUsed = new Rectangle(); for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; if (p.ScreenIndex == screenIndex) { playersUsing++; areaUsed = p.MonitorBounds; } } if (playersUsing == 2) { return(false); } int half = (int)(bounds.Width / 2.0f); for (int i = 0; i < 2; i++) { Rectangle area = new Rectangle(bounds.X + (half * i), bounds.Y, half, bounds.Height); if (!areaUsed.Contains(area)) { monitorBounds = area; int halfe = (int)(ebounds.Width / 2.0f); editorBounds = new Rectangle(ebounds.X + (halfe * i), ebounds.Y, halfe, ebounds.Height); return(true); } } } break; case UserScreenType.FourPlayers: { int playersUsing = 0; for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; if (p.ScreenIndex == screenIndex) { playersUsing++; } } if (playersUsing == 4) { return(false); } int halfw = (int)(bounds.Width / 2.0f); int halfh = (int)(bounds.Height / 2.0f); for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { Rectangle area = new Rectangle(bounds.X + (halfw * x), bounds.Y + (halfh * y), halfw, halfh); bool goNext = false; // check if there's any player with the area's x,y coord for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; if (p.ScreenIndex == screenIndex) { //if (p.MonitorBounds.X == area.X && // p.MonitorBounds.Y == area.Y) if (p.MonitorBounds.IntersectsWith(area)) { goNext = true; break; } } } if (goNext) { continue; } monitorBounds = area; int halfwe = (int)(ebounds.Width / 2.0f); int halfhe = (int)(ebounds.Height / 2.0f); editorBounds = new Rectangle(ebounds.X + (halfwe * x), ebounds.Y + (halfhe * y), halfwe, halfhe); return(true); } } } break; case UserScreenType.SixteenPlayers: { int playersUsing = 0; for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; if (p.ScreenIndex == screenIndex) { playersUsing++; } } if (playersUsing == 16) { return(false); } int halfw = (int)(bounds.Width / 4.0f); int halfh = (int)(bounds.Height / 4.0f); for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { Rectangle area = new Rectangle(bounds.X + (halfw * x), bounds.Y + (halfh * y), halfw, halfh); bool goNext = false; // check if there's any player with the area's x,y coord for (int i = 0; i < players.Count; i++) { PlayerInfo p = players[i]; if (p.ScreenIndex == screenIndex) { if (p.MonitorBounds.IntersectsWith(area)) { goNext = true; break; } } } if (goNext) { continue; } monitorBounds = area; int halfwe = (int)(ebounds.Width / 4.0f); int halfhe = (int)(ebounds.Height / 4.0f); editorBounds = new Rectangle(ebounds.X + (halfwe * x), ebounds.Y + (halfhe * y), halfwe, halfhe); return(true); } } } break; } return(false); }
private void UpdateScreens() { if (screens == null) { screens = ScreensUtil.AllScreens(); totalBounds = RectangleUtil.Union(screens); } else { UserScreen[] newScreens = ScreensUtil.AllScreens(); Rectangle newBounds = RectangleUtil.Union(newScreens); if (newBounds.Equals(totalBounds)) { return; } // screens got updated, need to reflect in our window screens = newScreens; totalBounds = newBounds; // remove all players screens List <PlayerInfo> playerData = profile.PlayerData; if (playerData != null) { for (int i = 0; i < playerData.Count; i++) { PlayerInfo player = playerData[i]; player.EditBounds = GetDefaultBounds(draggingIndex); player.ScreenIndex = -1; } } } screensArea = new RectangleF(10, 50 + Height * 0.2f + 10, Width - 20, Height * 0.5f); if (totalBounds.Width > totalBounds.Height) { // horizontal monitor setup scale = screensArea.Width / (float)totalBounds.Width; if (totalBounds.Height * scale > screensArea.Height) { scale = screensArea.Height / (float)totalBounds.Height; } } else { // vertical monitor setup scale = screensArea.Height / (float)totalBounds.Height; if (totalBounds.Width * scale > screensArea.Width) { scale = screensArea.Width / (float)totalBounds.Width; } } Rectangle scaledBounds = RectangleUtil.Scale(totalBounds, scale); scaledBounds.X = (int)screensArea.X; scaledBounds.Y = (int)screensArea.Y; //scaledBounds = RectangleUtil.Center(scaledBounds, RectangleUtil.Float(0, this.Height * 0.25f, this.Width, this.Height * 0.7f)); int minY = 0; for (int i = 0; i < screens.Length; i++) { UserScreen screen = screens[i]; Rectangle bounds = RectangleUtil.Scale(screen.MonitorBounds, scale); Rectangle uiBounds = new Rectangle(bounds.X, bounds.Y + scaledBounds.Y, bounds.Width, bounds.Height); screen.UIBounds = uiBounds; minY = Math.Min(minY, uiBounds.X); } // remove negative monitors minY = -minY; for (int i = 0; i < screens.Length; i++) { UserScreen screen = screens[i]; Rectangle uiBounds = screen.UIBounds; uiBounds.X += minY + scaledBounds.X; screen.UIBounds = uiBounds; screen.SwapTypeBounds = RectangleUtil.Float(uiBounds.X, uiBounds.Y, uiBounds.Width * 0.1f, uiBounds.Width * 0.1f); } }