private static void OnActorResize(object sender, AllocationChangedArgs args) { Actor actor = (Actor)sender; if (idleResizeId == 0) { idleResizeId = Threads.AddTimeoutFull(50, 1000, delegate { float width, height; actor.GetSize(out width, out height); ((Canvas)actor.Content).SetSize((int)Math.Ceiling(width), (int)Math.Ceiling(height)); idleResizeId = 0; return(false); }); } }
public static void Main(string[] args) { Actor actor; Stage stage; Canvas canvas; Application.Init(); stage = new Stage(); stage.Title = "2d clock"; stage.UserResizable = true; stage.BackgroundColor = Clutter.Color.New(114, 159, 207, 255); stage.SetSize(300, 300); stage.Show(); canvas = (Canvas)Canvas.New(); canvas.SetSize(300, 300); actor = new Actor(); actor.Content = canvas; actor.SetContentScalingFilters(ScalingFilter.Trilinear, ScalingFilter.Linear); stage.AddChild(actor); actor.AddConstraint(new BindConstraint(stage, BindCoordinate.Size, 0)); actor.AllocationChanged += OnActorResize; stage.Destroyed += (o, e) => Application.MainQuit(); canvas.Drawn += DrawClock; canvas.Invalidate(); Threads.AddTimeoutFull(10, 1000, delegate { canvas.Invalidate(); return(true); }); Clutter.Application.Main(); }