public override void MouseDown(int x, int y, bool isRightButton) { //check if we hit a lion or not //this is example => if right button=>test with path if (isRightButton) { if (LionMoveOption == LionMoveOption.Move) { LionMoveOption = LionMoveOption.ZoomAndRotate; } else { LionMoveOption = LionMoveOption.Move; } } //----------------------------------------------------- _hitLion = null; hitOnLion = false; for (int i = lionList.Count - 1; i >= 0; --i) { MyTestSprite lion = lionList[i]; if (lion.HitTest(x, y, isRightButton)) { hitOnLion = true; _hitLion = lion; break; } } base.MouseDown(x, y, isRightButton); }
public override void MouseDown(int x, int y, bool isRightButton) { //check if we hit a lion or not //this is example => if right button=>test with path if (isRightButton) { if (LionMoveOption == LionMoveOption.Move) { LionMoveOption = LionMoveOption.ZoomAndRotate; } else { LionMoveOption = LionMoveOption.Move; } } //----------------------------------------------------- _hitSprite = null; hitOnLion = false; for (int i = _spriteList.Count - 1; i >= 0; --i) { MyTestSprite sprite = _spriteList[i]; double testX = x; double testY = y; if (!sprite.JustMove && sprite.CurrentAffineTx != null) { sprite.CurrentAffineTx.Transform(ref testX, ref testY); } if (sprite.HitTest((float)testX, (float)testY, isRightButton)) { hitOnLion = true; _hitSprite = sprite; break; } } base.MouseDown(x, y, isRightButton); }
protected override void OnStart(AppHost host) { _host = host; _vgVisElem = VgVisualDocHelper.CreateVgVisualDocFromFile(@"Samples\lion.svg").VgRootElem; _mySprite = new MyTestSprite(_vgVisElem); var evListener = new GeneralEventListener(); evListener.MouseDown += e => { if (e.Button == UIMouseButtons.Right) { VgVisualElement foundE = _mySprite.HitTest(e.X, e.Y, true); if (foundE != null) { foundE.VisualSpec.FillColor = Color.Red; _mySprite.InvalidateLayout(); } } }; evListener.MouseMove += e => { if (e.Button == UIMouseButtons.Left && e.IsDragging) { if (e.Ctrl) { //TODO: //classic Agg's move and rotate } else { //just move _mySprite.SetLocation(_mySprite.X + e.XDiff, _mySprite.Y + e.YDiff); } } }; _mySprite.AttachExternalEventListener(evListener); host.AddChild(_mySprite); //// //var textbox = new LayoutFarm.CustomWidgets.TextBox(100, 30, false); //var textSpanStyle = new Text.TextSpanStyle(); ////test with various font style //textSpanStyle.FontInfo = new PixelFarm.Drawing.RequestFont("tahoma", 18); //textSpanStyle.FontColor = new PixelFarm.Drawing.Color(255, 0, 0); ////set default style //textbox.DefaultSpanStyle = textSpanStyle; //host.AddChild(textbox); //var box1 = new LayoutFarm.CustomWidgets.Box(50, 50); //box1.BackColor = Color.Red; //box1.SetLocation(10, 10); //host.AddChild(box1); ////-------------------------------- //var box2 = new LayoutFarm.CustomWidgets.Box(30, 30); //box2.SetLocation(50, 50); //host.AddChild(box2); ////1. mouse down //box1.MouseDown += (s, e) => //{ // box1.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); // box2.Visible = false; //}; //box1.MouseUp += (s, e) => //{ // box1.BackColor = Color.Red; // box2.Visible = true; //}; }