// ------------нажат "ПУСК"---------------- private void start_Click_1(object sender, EventArgs e) { // отключаем интерфейс LockInterface(); // запускаем таймер по которому будем перерисовывать сцену AnimationTimer.Start(); Experiment = new Experiment(R, BallDensity, LiquidDensity, Viscosity); }
private void OnResized(object sender, EventArgs e) { if (FormsContainer.MainForm.WindowState == FormWindowState.Normal && _animationState == AnimationState.Minimizing) { FormsContainer.MainForm.WindowState = FormWindowState.Normal; _animationState = AnimationState.Maximizing; AnimationTimer.Start(); } }
private void MSRTimerEventProcessor(Object myObject, EventArgs myEventArgs) { MSRTimer.Stop(); //MessageBox.Show("Timer done"); if (ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code) { AnimationPhase = 2; AnimationTimer.Start(); WashPlayer.PlayLooping(); (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + dd.plate; } else if (true)//CheckAuth(cardtoauth, ActiveNozz, ref limit, ref type, ref plate, ref reason)) { ps = PumpStatus.InUse; pup.ResetVol(conf.PumpAuthDelay); pup.SetStatus(ps, dd.limit, dd.type, dd.plate, conf.flowrate, -1); //AddToLogList(MsgLogType.Authorized, reason, 0, plate, limit, dd.cardnum); (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + dd.plate; if (dd.type == "Money") { (MainPage.Document.GetElementById("Limit")).InnerHtml = dd.limit.ToString("0") + " " + conf.LimitPerMoneyText; } else { (MainPage.Document.GetElementById("Limit")).InnerHtml = dd.limit.ToString("0") + " " + conf.LimitPerVolText; } } else if (reason == "CPass required") { AddToLogList(MsgLogType.CheckCPass, reason, 0, plate, limit, cardtoauth); MSRTimer.Start(); //recheck in as few seconds } else if (reason == "CPass wait") { //AddToLogList(MsgLogType.CheckCPass, reason, 0, plate, limit, cardtoauth); //no second message if (CPassTry == conf.CPassRetry) { reason = "No mobile confirmation"; if (statustouse != 0x30) { AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, gotmsg.carddata); } return; } CPassTry++; MSRTimer.Start(); //recheck in as few seconds } else { if (statustouse != 0x30) { AddToLogList(MsgLogType.CannotAuth, reason, 0, plate, limit, gotmsg.carddata); } } }
// Инициализация private void Form1_Load(object sender, EventArgs e) { OpenGlInit(); DevIlInit(); AnimationTimer.Start(); logger = new StreamWriter("logger.txt", true); listener = new MyListener(); listener.output += (string s) => { logger.WriteLine(s); }; controller = new Controller(); controller.AddListener(listener); }
public Form1() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterScreen; // Use DoubleBuffered to stop flickering at Refresh method this.DoubleBuffered = true; // Declare new game, setting game boundaries game = new Game(this.DisplayRectangle); // Start the animation timer straight away - animate stars and sets refreshing interval bitmap = new Bitmap(this.Width, this.Height); graphics = Graphics.FromImage(bitmap); AnimationTimer.Interval = Parameters.animationTimerInterval; AnimationTimer.Start(); }
/// <summary> /// Starts and Stops all of the game-play timers. /// </summary> /// <returns></returns> public bool StartPause() { if (!running) { AnimationTimer.Start(); AsteroidTimer.Start(); HealthTimer.Start(); return(true); } else { AnimationTimer.Stop(); AsteroidTimer.Stop(); HealthTimer.Stop(); Invalidate(); return(false); } }
/// <summary> /// Logic implement Destroying a Bomb /// Hide unnecessary pictures /// Show destroing animation, reset the constants and spawn new bomb. /// </summary> private void DestroyBomb() { PlaySound.PlayExplodeSound(); BombPB.Hide(); RocketPB.Hide(); LaserPB.Hide(); ExplodingAsteroid.Left = BombPB.Left - 10; ExplodingAsteroid.Top = BombPB.Top - 20; ExplodingAsteroid.Show(); destroyed = true; nukeCity = false; Bomb.IsExploding = false; Rocket.IsFired = false; Bomb.Life = 3; SpawnNewBomb(); ScoreCounter(); AnimationTimer.Start(); }
void createCanvas (List <ExtendedBitmap> movie, Point point, out Canvas canvas, out World world) { if (this.прозрачностьToolStripMenuItem.Checked || this.прозрачностьТеньToolStripMenuItem.Checked) { movie = movie.ConvertAll <ExtendedBitmap>( delegate(ExtendedBitmap exBm) { exBm = exBm.Clone(); Bitmap bm = exBm.Bm; ColorPalette tempPalette = bm.Palette; if (tempPalette.Entries.Length >= 255) { if (this.прозрачностьToolStripMenuItem.Checked) { tempPalette.Entries[0] = Color.Transparent; } if (this.прозрачностьТеньToolStripMenuItem.Checked) { tempPalette.Entries[254] = Color.Transparent; } bm.Palette = tempPalette; } return(exBm); }); } List <ExtendedBitmap> tileMovie = new List <ExtendedBitmap>(); //foreach (ExtendedBitmap exBm in movie) if (this.отрисовыватьТайлToolStripMenuItem.Checked) { tileMovie.Add(new ExtendedBitmap(dotNetStiEditor.Properties.Resources.Tile, 0, 0)); } else { tileMovie.Add(new ExtendedBitmap(new Bitmap(1, 1), 0, 0)); } canvas = new Canvas(movie); TileCanvas = new Canvas(tileMovie); world = new World(); this.graphics = this.pictureBox1.CreateGraphics(); world.CreateViewport(pictureBox1, this.graphics, point, new Rectangle(point, new Size((pictureBox1.Width - 30) / 2, pictureBox1.Height)), pictureBox1.Image, this.прозрачностьToolStripMenuItem.Checked); world.AddSprite(TileCanvas, new Point(), 0, 15, false, false); world.AddSprite(canvas, point, 0, 15, false, true); Sprite sprite = world.Library.Item(1); ExtendedBitmap firstExBm = canvas.PictureFile[0]; Point tilePosition = sprite.TilePosition; if (firstExBm.ApplicationData != null) { tilePosition.Offset(-20, -10); } world.Library.Item(0).oPosition = tilePosition; this.FPSScroll.Value = 15; textBox2.Text = "15"; FPStimer.Start(); timer.Start(); AnimationTimer.Start(); world.RequestRendering(0); world.RequestRendering(1); }
private void ShowMSRProgress(MSRStatusData msg) { Thread.BeginCriticalRegion(); try { if (msg.status == -1) { AddToLogList(MsgLogType.MSRCommError, "", 0, "", 0, msg.carddata); return; } if ((ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code) && msg.msg == MsgLogType.MSRWrongProduct) //we are in wash? { if (ProductCode == conf.Wash1Code) { Wash1Clicked(); //simulate relese } else { Wash2Clicked(); } } if (msg.msg != MsgLogType.MSRAuth) //just update the status { AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata); msgSaved = null; return; } if (ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code) //we are in wash? { AnimationPhase = 2; WashInProgress = true; AnimationTimer.Start(); WashPlayer.PlayLooping(); (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + msg.DriverName; lastamount = 490; //wash price lastvol = 0; bool found = false; MyProductItem itemfound = null; foreach (MyProductItem item in msg.ProductsList) { if (item.Code == ProductCode) { found = true; itemfound = item; break; } } if (found) { //check discount if (itemfound.DiscountType == "%") { lastamount = lastamount * (1 - itemfound.Discount / 100); (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "%"; } else { lastamount = lastamount - itemfound.Discount; (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "c"; } } return; } //we got authorization check if pump is ready switch (ps) { case PumpStatus.Idle: AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata); AddToLogList(MsgLogType.MSRSSelectProduct, "", 0, "", 0, ""); //save auth data msgSaved = msg; break; case PumpStatus.Call: AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata); if (msg.msg == MsgLogType.MSRAuth) { dd = new DeviceData(); dd.bCPass = false; dd.cardnum = msg.carddata; dd.limit = msg.Limit; dd.plate = msg.DriverName; dd.type = msg.LimitType; dd.bCPass = msg.CPassRequired; MobileRes = "None"; CPassTry = 0; MsgID++; //find the product discount bool found = false; MyProductItem itemfound = null; foreach (MyProductItem item in msg.ProductsList) { if (item.Code == ProductCode) { found = true; itemfound = item; break; } } if (found) { //check limit type if (itemfound.DiscountType == "%") { UpdatePPVPrecent(itemfound.Discount); (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "%"; } else { UpdatePPVAbs(itemfound.Discount); (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "c"; } } MSRTimer.Start(); } break; } } catch (Exception ex) { // MessageBox.Show(ex.Message); } finally { Thread.EndCriticalRegion(); } }
/// <summary> /// The logic implement movement of gifts and asteroids and calculating using a timer /// </summary> private void AsteroidPositionTimer_Tick(object sender, EventArgs e) { /// <summary> /// Stop timer, when the game is not start with start buton /// </summary> if (!StartGame.GameIsStarted()) { AsteroidPositionTimer.Stop(); } /// <summary> /// If an asteroid and a gift appear at the same place, new coordinates are calculated /// </summary> if (Gift.ContentShowTyme > 0) { Gift.ContentShowTyme--; if (Gift.ContentShowTyme == 0) { RocketGift.Hide(); DashboardGiftLabel.Hide(); } } /// <summary> /// Look Rocket.cs class /// </summary> if (Rocket.IsFired) { Rocket.Move(RocketPB); } /// <summary> /// Chek count laser hits on asteroid and when asteroid is dead, hide Laser from the screen. /// </summary> if (Laser.TimeCounter > 0) { Laser.TimeCounter--; } else { LaserPB.Hide(); } /// <summary> /// If asteroid is hiting by laser or rocket, we destroying him. /// </summary> if (Bomb.IsExploding) { DestroyBomb(); } /// <summary> /// Set new coordinates on asteroid and show bomb. /// </summary> Bomb.Y += 7; BombPB.Location = new Point(Bomb.X, Bomb.Y); BombPB.Show(); /// <summary> /// Chek coordinates and explode asteroid random on screen. /// </summary> if (Bomb.Y >= rnd.Next(380, 470) && !Bomb.IsExploding) { nukeCity = true; nukeCloudCounter = 0; AnimationTimer.Start(); } /// <summary> /// If gift is hiting by laser or rocket, we destroying him. /// </summary> if (Gift.IsExploding) { DestroyGift(); } /// <summary> /// Logic encompasses the movement and the disappearance of the gift when it's not hiting. /// </summary> if (isGiftVisible) { if (Gift.Y >= 700) { isGiftVisible = false; RedGift.Hide(); } else { Gift.Y += 5; RedGift.Location = new Point(Gift.X, Gift.Y); } } else { isGiftVisible = rnd.Next(0, 50) == 1; if (isGiftVisible) { SpawnGift(); } } }
/// <summary> /// Listens for keys pressed /// </summary> /// <param name="sender">key pressed object</param> /// <param name="e">Key event arguments</param> private void GameForm_KeyDown(object sender, KeyEventArgs e) { if (AnimationTimer.Enabled) { switch (e.KeyData) { case Keys.Left: { if (!KeyList.Contains(Keys.Left)) { KeyList.Add(Keys.Left); } break; } case Keys.Right: { if (!KeyList.Contains(Keys.Right)) { KeyList.Add(Keys.Right); } break; } case Keys.Up: { if (!KeyList.Contains(Keys.Up)) { KeyList.Add(Keys.Up); } break; } case Keys.Down: { if (!KeyList.Contains(Keys.Down)) { KeyList.Add(Keys.Down); } break; } } } if (e.KeyData == Keys.Space) { if (gameStart) { gameStart = false; } if (AnimationTimer.Enabled) { paused = true; AnimationTimer.Stop(); BallTimer.Stop(); Invalidate(); } else { paused = false; AnimationTimer.Start(); BallTimer.Start(); } } }
private void PlayOpenAnimation() { Opacity = 0.0; _animationState = AnimationState.Opening; AnimationTimer.Start(); }
private void PlayCloseAnimation() { _animationState = AnimationState.Closing; AnimationTimer.Start(); }
private void OnMinimizeButtonClicked(object sender, EventArgs e) { _animationState = AnimationState.Minimizing; AnimationTimer.Start(); }