private void ThumbnailList_MouseLeave(object sender, EventArgs e) { hoverItem = -1; addButtonHover = false; Invalidate(); if (ItemHover != null) { ItemHover.Invoke(this, null); } }
private void TourStopList_MouseLeave(object sender, EventArgs e) { hoverItem = -1; TransitionHighlighted = false; addButtonHover = false; Refresh(); if (ItemHover != null) { ItemHover.Invoke(this, null); } }
private Image getMouseOverImage(Image img, Item item) { var itemhover = new ItemHover() { DataContext = ItemHoverViewModelFactory.Create(item) }; Popup popup = new Popup(); popup.PopupAnimation = PopupAnimation.None; popup.StaysOpen = true; popup.Child = itemhover; popup.PlacementTarget = img; img.MouseEnter += (o, e) => { popup.IsOpen = true; }; img.MouseLeave += (o, e) => { popup.IsOpen = false; img = null; GC.Collect(); }; return(img); }
private void ThumbnailList_MouseMove(object sender, MouseEventArgs e) { bool imageClicked; int newHover = GetItemIndexFromCursor(e.Location, out imageClicked); if (hoverItem != newHover) { hoverItem = newHover; if (ItemHover != null) { if (hoverItem > -1) { ItemHover.Invoke(this, items[hoverItem]); } else { ItemHover.Invoke(this, null); } } } Invalidate(); }
public Image getImage() { Image img = new Image(); if (!imageCache.ContainsKey(Item.IconURL)) { using (var stream = ApplicationState.Model.GetImage(Item)) { var bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = stream; bitmap.CacheOption = BitmapCacheOption.OnLoad; bitmap.EndInit(); bitmap.Freeze(); imageCache.Add(Item.IconURL, bitmap); } } img.Source = imageCache[Item.IconURL]; var itemhover = new ItemHover() { DataContext = ItemHoverViewModelFactory.Create(Item) }; Popup popup = new Popup(); popup.AllowsTransparency = true; popup.PopupAnimation = PopupAnimation.None; popup.StaysOpen = true; popup.Child = itemhover; popup.PlacementTarget = img; img.Stretch = Stretch.None; img.MouseEnter += (o, e) => { popup.IsOpen = true; }; img.MouseLeave += (o, e) => { btns_MouseLeave(popup, e); img = null; GC.Collect(); }; return(img); }
private void Parent_MouseLeave(object sender, MouseEventArgs e) { Visibility = Visibility.Hidden; ItemHover?.Invoke(-1); }
private void TourStopList_MouseMove(object sender, MouseEventArgs e) { if (scrolling) { int scrollbarWidth = Width; int scrollbarStart = 0; float scrollUnit = (1f / (float)(TotalItems + 1) * Width); scrollbarWidth = Math.Max(14, (int)(Math.Min(1.0f, (float)ItemsPerPage / (float)(TotalItems + 1)) * (float)Width)); scrollbarStart = (int)(((float)startIndex / (float)(TotalItems + 1)) * (float)Width); int dragDist = pointDown.X - e.X; startIndex = Math.Max(0, Math.Min((TotalItems + 1) - (ItemsPerPage), scrollStartIndex - (int)(dragDist / scrollUnit))); Refresh(); return; } if (mouseDown) { if (Tour.EditMode) { if (dragging) { Point pntTemp = Control.MousePosition; pntTemp.Offset(-48, -27); dragThumbnail.Location = pntTemp; dragDropItemLocation = GetItemIndexFromCursor(e.Location); Refresh(); } else { Point pntTest = pointDown; pntTest.Offset(-e.Location.X, -e.Location.Y); if (Math.Abs(pntTest.X) > 5 || Math.Abs(pntTest.Y) > 5) { dragItem = GetItemIndexFromCursor(e.Location); if (dragItem > -1) { dragging = true; dragThumbnail = new DragThumbnail(); Point pntTemp = this.PointToScreen(Control.MousePosition); pntTemp.Offset(-48, -27); dragThumbnail.Location = pntTemp; dragThumbnail.Thumbnail = Items[dragItem].Thumbnail; dragThumbnail.Show(); } else { mouseDown = false; } } } } } else { int newHover = GetItemIndexFromCursor(e.Location); if (hoverItem != newHover) { hoverItem = newHover; if (ItemHover != null) { if (hoverItem > -1) { ItemHover.Invoke(this, Items[hoverItem]); } else { ItemHover.Invoke(this, null); } } } Refresh(); TransitionHighlighted = false; switch (GetCusorSytleFromCursorPosition(e.Location)) { case HitPosition.Default: Cursor.Current = Cursors.Default; break; case HitPosition.Drag: Cursor.Current = Cursors.Hand; break; case HitPosition.EditName: Cursor.Current = Cursors.IBeam; break; case HitPosition.EditTime: Cursor.Current = Cursors.IBeam; break; case HitPosition.StartPosition: case HitPosition.EndPosition: Cursor.Current = Cursors.Arrow; break; case HitPosition.Transition: Cursor.Current = Cursors.Arrow; TransitionHighlighted = true; break; default: Cursor.Current = Cursors.Default; break; } } }