static void Main(String[] args) { if (Application.Init() != InitError.Success) { return; } var stage = new Stage(); var image = (Image)Image.New(); var action = new TapAction(); var text = new Text(); var pixbuf = new Pixbuf("redhand.png"); stage.Name = "Stage"; stage.Title = "Content Box"; stage.UserResizable = true; stage.Destroyed += (sender, e) => Application.MainQuit(); stage.MarginTop = 12; stage.MarginBottom = 12; stage.MarginLeft = 12; stage.MarginRight = 12; stage.Show(); image.SetData(pixbuf.Pixels, pixbuf.HasAlpha ? Cogl.PixelFormat.Rgba8888 : Cogl.PixelFormat.Rgb888, (uint)pixbuf.Width, (uint)pixbuf.Height, (uint)pixbuf.Rowstride); stage.SetContentScalingFilters(ScalingFilter.Trilinear, ScalingFilter.Linear); stage.ContentGravity = gravities.Last <ContentGravity>(); stage.Content = image; text.TextProp = "Content gravity: " + gravities.Last <ContentGravity>(); text.AddConstraint(new AlignConstraint(stage, AlignAxis.Both, 0.5f)); stage.AddChild(text); action.Tapped += (object o, TappedArgs arg) => { var actor = arg.Actor; actor.SaveEasingState(); actor.ContentGravity = gravities [currentGravity]; actor.RestoreEasingState(); text.TextProp = "Content gravity: " + gravities [currentGravity]; currentGravity++; if (currentGravity >= gravities.Count) { currentGravity = 0; } }; stage.AddAction(action); Application.Main(); }
void onFlagReleased(Flag flag) { Vector3 from = flag.PrevFlagPosition; Vector3 to = flag.transform.position; if (Vector3.Distance(from, to) > GlobalConst.EPSILON) { StageAction stageAction = new MoveNodeAction(flags.IndexOf(flag), from, to); stage.AddAction(stageAction); } refreshLineRenderer(); synchronizeModelWithFlags(); }