private void CurrentPreview_PagesCalculated(object sender, EventArgs e) { if (changingSheetSize) { return; } changingSheetSize = true; int cols = Math.Min(currentPreview.Document.PageColumns, maxAutoColumns); int rows = Math.Min(currentPreview.Document.PageRows, maxAutoRows); // achieve a more "symmetric" look if (cols == 1) { rows = 1; } SyncRowsColumns(cols, rows); changingSheetSize = false; // HACK: The ... GTK sends key events not to the current tab unless it's "focused" Timeout.Add(0, () => { (btnPrint.Sensitive ? btnPrint : btnClose).GrabFocus(); return(false); }); }
/// <summary> /// Constructs the display and sets up the internal widgets. /// </summary> public Display() { // Set up our size tileSize = 72; SetSizeRequest( tileSize * Game.Config.BoardSize, tileSize * Game.Config.BoardSize); // Create our viewport sprites = new SpriteList(); viewport = new SpriteViewport(sprites); // Set up the events ExposeEvent += OnExposed; ConfigureEvent += OnConfigure; ButtonPressEvent += OnButtonPress; Events = EventMask.AllEventsMask; // Set up the animation timer Timeout.Add(1000 / Game.Config.FramesPerSecond, OnTick); log = new Log(); }
/// <summary> /// Triggered on the animation loop. /// </summary> private bool OnTick() { // Check state if (Game.State == GameState.Started) { Game.State = GameState.InProgress; } if (lastState != Game.State) { // Check for game over if (Game.State == GameState.Completed) { // Wipe everything sprites.Clear(); // Add game over screen AddGameOver(); } // Save the state lastState = Game.State; } // Update the sprites sprites.Update(); // Remove any completed animations LinkedList <BurntSprite> list = new LinkedList <BurntSprite>(); foreach (ISprite sprite in sprites) { BurntSprite bs = sprite as BurntSprite; if (bs != null && bs.CanRemove) { list.Add(bs); } } foreach (BurntSprite bs in list) { sprites.Remove(bs); } // Render the pane viewport.FireQueueDraw(this); // Handle the tick updating tickCount++; if (tickCount % 100 == 0) { int fps = (int)Game.Config.FramesPerSecond; double diff = (DateTime.UtcNow.Ticks - start) / 10000000.0; double efps = exposeCount / diff; double tfps = tickCount / diff; Console.WriteLine( "FPS: Exposed {0:N1} FPS ({3:N1}%), " + "Ticks {1:N1} FPS ({4:N1}%), " + "Maximum {2:N0} FPS", efps, tfps, fps, efps * 100 / fps, tfps * 100 / fps); start = DateTime.UtcNow.Ticks; exposeCount = tickCount = 0; } // Re-request the animation Timeout.Add(1000 / Game.Config.FramesPerSecond, OnTick); return(false); }
private void InitializeLocationsGrid() { gridLocations = new ListView { Name = "gridLocations", WidthRequest = 250, HeightRequest = 400, AllowMultipleSelect = false }; gridLocations.Selection.Changed += Selection_Changed; gridLocations.ColumnController = new ColumnController { new Column(Translator.GetString("Location"), "Name", 1, "Name") }; scwLocations.Add(gridLocations); gridLocations.Show(); allLocations = Location.GetAll(); bool recreated = false; bool retry; do { retry = false; allStartNumbers = OperationNumberingInfo.Get(); if (allStartNumbers.Length == 0) { OperationNumberingInfo.Create(); recreated = true; allStartNumbers = OperationNumberingInfo.Get(); } allStartNumbersPerLocation.Clear(); foreach (Location location in allLocations) { Location l = location; List <OperationNumberingInfo> operations = allStartNumbers.Where(o => o.LocationId == l.Id).ToList(); if (operations.Count == 0 && !recreated) { OperationNumberingInfo.Create(); retry = true; recreated = true; break; } foreach (var info in operations) { info.UsageDescription = Translator.GetString("Calculating..."); } allStartNumbersPerLocation.Add(new KeyValuePair <long, BindingListModel <OperationNumberingInfo> > (location.Id, new BindingListModel <OperationNumberingInfo> (operations))); } } while (retry); DataHelper.FireAndForget(() => { numbersUsagePerLocation = OperationNumbersUsage.Get(); numbersUsageStarts = OperationNumbersUsage.GetUsagesStarts(); Timeout.Add(0, () => { try { UpdateDocumentsUsage(); } catch (ArgumentOutOfRangeException) { } return(false); }); }); allStartNumbersPerLocation = allStartNumbersPerLocation.OrderBy(p => p.Value.Min(o => o.StartNumber)).ToList(); // Use a model with natural order by the operation number intervals gridLocations.Model = new BindingListModel <Location> (allStartNumbersPerLocation.Select(d => allLocations.Find(p => p.Id == d.Key))); lblCurrentLocationsValue.SetText(allLocations.Count.ToString("N", formatBigNumber)); if (gridLocations.Model.Count <= 0) { return; } gridLocations.FocusRow(0); gridLocations.Selection.Select(0); gridLocations.ScrollToV(0); }