/// <summary> /// Mouse down /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DxContainer_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (selectedBoard == null) { return; } // If the mouse has not been moved while we were in focus (e.g. when clicking on the editor while another window focused), this event will be sent without a mousemove event preceding it. // We will move it to its correct position by invoking the move event handler manually. if (selectedBoard.Mouse.X != e.X || selectedBoard.Mouse.Y != e.Y) { // No need to lock because MouseMove locks anyway DxContainer_MouseMove(sender, e); } selectedBoard.Mouse.IsDown = true; if (e.Button == System.Windows.Forms.MouseButtons.Left && LeftMouseDown != null) { bool selectedItemHigher; Point realPosition = new Point(e.X, e.Y); lock (this) { BoardItemPair objsUnderMouse = GetObjectsUnderPoint(realPosition, out selectedItemHigher); LeftMouseDown(selectedBoard, objsUnderMouse.NonSelectedItem, objsUnderMouse.SelectedItem, realPosition, new Point(PhysicalToVirtual(e.X, selectedBoard.CenterPoint.X, selectedBoard.hScroll, 0), PhysicalToVirtual(e.Y, selectedBoard.CenterPoint.Y, selectedBoard.vScroll, 0)), selectedItemHigher); } } }
private BoardItem GetObjectUnderPoint(Point location) { bool selectedItemHigher; BoardItemPair objsUnderPoint = GetObjectsUnderPoint(location, out selectedItemHigher); if (objsUnderPoint.SelectedItem == null && objsUnderPoint.NonSelectedItem == null) return null; else if (objsUnderPoint.SelectedItem == null) return objsUnderPoint.NonSelectedItem; else if (objsUnderPoint.NonSelectedItem == null) return objsUnderPoint.SelectedItem; else return selectedItemHigher ? objsUnderPoint.SelectedItem : objsUnderPoint.NonSelectedItem; }
private BoardItem GetObjectUnderPoint(Point location) { bool selectedItemHigher; BoardItemPair objsUnderPoint = GetObjectsUnderPoint(location, out selectedItemHigher); if (objsUnderPoint.SelectedItem == null && objsUnderPoint.NonSelectedItem == null) { return(null); } else if (objsUnderPoint.SelectedItem == null) { return(objsUnderPoint.NonSelectedItem); } else if (objsUnderPoint.NonSelectedItem == null) { return(objsUnderPoint.SelectedItem); } else { return(selectedItemHigher ? objsUnderPoint.SelectedItem : objsUnderPoint.NonSelectedItem); } //BoardItem itemUnderPoint = null; //Point locationVirtualPos = new Point(PhysicalToVirtual(location.X, selectedBoard.CenterPoint.X, selectedBoard.hScroll, /*item.Origin.X*/0), PhysicalToVirtual(location.Y, selectedBoard.CenterPoint.Y, selectedBoard.vScroll, /*item.Origin.Y*/0)); /*if ((ApplicationSettings.editedTypes & ItemTypes.Backgrounds) == ItemTypes.Backgrounds) * GetObjUnderPointFromBackgroundList(locationVirtualPos, ref itemUnderPoint, false); * if (((ApplicationSettings.editedTypes & ItemTypes.Tiles) == ItemTypes.Tiles) && ((ApplicationSettings.editedTypes & ItemTypes.Objects) == ItemTypes.Objects)) * GetObjUnderPointFromList(selectedBoard.BoardItems.TileObjs, locationVirtualPos, ref itemUnderPoint, false); * else if (((ApplicationSettings.editedTypes & ItemTypes.Tiles) == ItemTypes.Tiles) || ((ApplicationSettings.editedTypes & ItemTypes.Objects) == ItemTypes.Objects)) * GetObjUnderPointFromList(selectedBoard.BoardItems.TileObjs, locationVirtualPos, ref itemUnderPoint, true); * if((ApplicationSettings.editedTypes & ItemTypes.Mobs) == ItemTypes.Mobs) * GetObjUnderPointFromList(selectedBoard.BoardItems.Mobs, locationVirtualPos, ref itemUnderPoint, false); * if ((ApplicationSettings.editedTypes & ItemTypes.NPCs) == ItemTypes.NPCs) * GetObjUnderPointFromList(selectedBoard.BoardItems.NPCs, locationVirtualPos, ref itemUnderPoint, false); * if ((ApplicationSettings.editedTypes & ItemTypes.Reactors) == ItemTypes.Reactors) * GetObjUnderPointFromList(selectedBoard.BoardItems.Reactors, locationVirtualPos, ref itemUnderPoint, false); * if ((ApplicationSettings.editedTypes & ItemTypes.Portals) == ItemTypes.Portals) * GetObjUnderPointFromList(selectedBoard.BoardItems.Portals, locationVirtualPos, ref itemUnderPoint, false); * if ((ApplicationSettings.editedTypes & ItemTypes.Backgrounds) == ItemTypes.Backgrounds) * GetObjUnderPointFromBackgroundList(locationVirtualPos, ref itemUnderPoint, true); * if ((ApplicationSettings.editedTypes & ItemTypes.Footholds) == ItemTypes.Footholds) * GetObjUnderPointFromList(selectedBoard.BoardItems.FHAnchors, locationVirtualPos, ref itemUnderPoint, false); * if ((ApplicationSettings.editedTypes & ItemTypes.Ropes) == ItemTypes.Ropes) * GetObjUnderPointFromList(selectedBoard.BoardItems.RopeAnchors, locationVirtualPos, ref itemUnderPoint, false); * if ((ApplicationSettings.editedTypes & ItemTypes.Chairs) == ItemTypes.Chairs) * GetObjUnderPointFromList(selectedBoard.BoardItems.Chairs, locationVirtualPos, ref itemUnderPoint, false); * if ((ApplicationSettings.editedTypes & ItemTypes.ToolTips) == ItemTypes.ToolTips) * { * GetObjUnderPointFromList(selectedBoard.BoardItems.CharacterToolTips, locationVirtualPos, ref itemUnderPoint, false); * GetObjUnderPointFromList(selectedBoard.BoardItems.ToolTips, locationVirtualPos, ref itemUnderPoint, false); * GetObjUnderPointFromList(selectedBoard.BoardItems.ToolTipDots, locationVirtualPos, ref itemUnderPoint, false); * } * return itemUnderPoint;*/ }
/// <summary> /// Mouse up /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DxContainer_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { selectedBoard.Mouse.IsDown = false; if (e.Button == System.Windows.Forms.MouseButtons.Left && LeftMouseUp != null) { Point realPosition = new Point(e.X, e.Y); bool selectedItemHigher; lock (this) { BoardItemPair objsUnderMouse = GetObjectsUnderPoint(realPosition, out selectedItemHigher); LeftMouseUp(selectedBoard, objsUnderMouse.NonSelectedItem, objsUnderMouse.SelectedItem, realPosition, new Point(PhysicalToVirtual(e.X, selectedBoard.CenterPoint.X, selectedBoard.hScroll, 0), PhysicalToVirtual(e.Y, selectedBoard.CenterPoint.Y, selectedBoard.vScroll, 0)), selectedItemHigher); } } }
private void DxContainer_MouseUp(object sender, MouseEventArgs e) { selectedBoard.Mouse.IsDown = false; if (e.Button == MouseButtons.Left && LeftMouseUp != null) { Point realPosition = new Point(e.X, e.Y); bool selectedItemHigher; BoardItemPair objsUnderMouse = GetObjectsUnderPoint(realPosition, out selectedItemHigher); LeftMouseUp(selectedBoard, objsUnderMouse.NonSelectedItem, objsUnderMouse.SelectedItem, realPosition, new Point(PhysicalToVirtual(e.X, selectedBoard.CenterPoint.X, selectedBoard.hScroll, 0), PhysicalToVirtual(e.Y, selectedBoard.CenterPoint.Y, selectedBoard.vScroll, 0)), selectedItemHigher); } if (deviceReady) { RenderFrame(); } }
private BoardItem GetObjectUnderPoint(Point location) { bool selectedItemHigher; BoardItemPair objsUnderPoint = GetObjectsUnderPoint(location, out selectedItemHigher); if (objsUnderPoint.SelectedItem == null && objsUnderPoint.NonSelectedItem == null) { return(null); } else if (objsUnderPoint.SelectedItem == null) { return(objsUnderPoint.NonSelectedItem); } else if (objsUnderPoint.NonSelectedItem == null) { return(objsUnderPoint.SelectedItem); } else { return(selectedItemHigher ? objsUnderPoint.SelectedItem : objsUnderPoint.NonSelectedItem); } }