private void TourStopList_MouseUp(object sender, MouseEventArgs e) { dragging = false; mouseDown = false; scrolling = false; if (dragThumbnail != null) { if (dragItem > -1 && dragItem != dragDropItemLocation) { if (dragDropItemLocation != -1) { if (dragDropItemLocation == -2) { dragDropItemLocation = Items.Count; } List <TourStop> dragItems = new List <TourStop>(); foreach (int itemId in SelectedItems.Keys) { dragItems.Add(Items[itemId]); } //TourStop ts = Items[dragItem]; if (Control.ModifierKeys != Keys.Control) { Undo.Push(new UndoTourSlidelistChange(Language.GetLocalizedText(550, "Move Slide"), Tour)); foreach (TourStop ts in dragItems) { Items.Remove(ts); } int itemCount = 0; foreach (int selIndex in SelectedItems.Keys) { if (dragDropItemLocation > dragItem) { itemCount++; } } dragDropItemLocation -= itemCount; SelectedItems.Clear(); foreach (TourStop ts in dragItems) { Items.Insert(dragDropItemLocation, ts); SelectedItems.Add(dragDropItemLocation, Items[dragDropItemLocation]); dragDropItemLocation++; } } else { Undo.Push(new UndoTourSlidelistChange(Language.GetLocalizedText(539, "Drag Copy"), Tour)); SelectedItems.Clear(); foreach (TourStop ts in dragItems) { Items.Insert(dragDropItemLocation, ts.Copy()); SelectedItems.Add(dragDropItemLocation, Items[dragDropItemLocation]); dragDropItemLocation++; } } Tour.CurrentTourstopIndex = selectedItem = dragDropItemLocation; Refresh(); } } dragThumbnail.Close(); dragThumbnail.Dispose(); dragThumbnail = null; } dragDropItemLocation = -1; dragItem = -1; }
private void TourStopList_Paint(object sender, PaintEventArgs e) { multipleSelection = SelectedItems.Count > 1; if (selectedItem != -1 && Items.Count > 0 && SelectedItems.Count == 0) { selectedItem = Math.Min(selectedItem, Items.Count - 1); SelectedItems.Add(selectedItem, Items[selectedItem]); } Graphics g = e.Graphics; RowCount = Math.Max(Height / ThumbHeight, 1); ColCount = Math.Max(Width / HorzSpacing, 1); TotalItems = Items.Count; horzMultiple = HorzSpacing; int index = startIndex; Pen p = new Pen(Color.FromArgb(62, 73, 92)); g.DrawRectangle(p, new Rectangle(0, 0, Width - 1, Height - 1)); p.Dispose(); // Draw scrollbar g.DrawImageUnscaled(bmpScrollBackLeft, 0, 0); for (int j = 10; j < Width - 10; j += 50) { g.DrawImageUnscaled(bmpScrollBackMiddle, j, 0); } g.DrawImageUnscaled(bmpScrollBackRight, Width - 10, 0); int scrollbarWidth = Width; int scrollbarStart = 0; 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); g.DrawImageUnscaled(bmpScrollBarLeft, scrollbarStart, 1); for (int j = scrollbarStart + 10; j < (scrollbarWidth + scrollbarStart) - 10; j += 50) { g.DrawImageUnscaledAndClipped(bmpScrollBarMiddle, new Rectangle(j, 1, Math.Min(50, ((scrollbarWidth + scrollbarStart) - j) - 10), 6)); } g.DrawImageUnscaled(bmpScrollBarRight, (scrollbarStart + scrollbarWidth) - 10, 1); for (int y = 0; y < rowCount; y++) { for (int x = 0; x < colCount; x++) { RectangleF rectf = new RectangleF((float)x * horzMultiple + 47f, y * VertSpacing + 20, ThumbWidth - 10, 64); Brush textBrush = UiTools.StadardTextBrush; if (index >= Items.Count) { if (this.dragDropItemLocation == -2) { g.DrawImage(bmpDropInsertMarker, (int)((float)x * horzMultiple) + 34, (int)((float)y * VertSpacing) + 20); //g.DrawRectangle(Pens.Yellow, new Rectangle((int)((float)x * horzMultiple), (int)((float)y * VertSpacing + 1), 1, VertSpacing - 22)); } if (showAddButton) { if (addButtonHover && !dragging) { g.DrawImage(thumbnailSize == ThumbnailSize.Big ? bmpBackgroundWideHover : bmpBackgroundHover, (int)((float)x * horzMultiple + 44), y * VertSpacing + 20); textBrush = UiTools.YellowTextBrush; } else { g.DrawImage(thumbnailSize == ThumbnailSize.Big ? bmpBackgroundWide : bmpBackground, (int)((float)x * horzMultiple + 44), y * VertSpacing + 20); } // Changed + 33f to + 21f to accomodate slightly longer "add new slide" string: Peter rectf = new RectangleF((float)x * horzMultiple + 55f, y * VertSpacing, ThumbWidth - 17, 62); // Changed "Add a slide" to "Add New Slide" in order to pick up a localized string: Peter g.DrawString(Language.GetLocalizedText(426, "Add New Slide"), UiTools.StandardRegular, textBrush, rectf, UiTools.StringFormatThumbnails); } break; } // Removed hover because of confusion with selection and current slide //if (index == hoverItem || (index == selectedItem && hoverItem == -1)) // if (index == selectedItem && !dragging && !TransitionHighlighted) if (SelectedItems.ContainsKey(index) && !dragging && (!TransitionHighlighted || multipleSelection)) { g.DrawImage(thumbnailSize == ThumbnailSize.Big ? bmpBackgroundWideHover : bmpBackgroundHover, (int)((float)x * horzMultiple + 44), y * VertSpacing + 20); textBrush = UiTools.YellowTextBrush; if (Items[index].Owner.EditMode && !multipleSelection) { g.DrawImage(bmpPunchInOutBlock, (int)((float)x * horzMultiple + 44), y * VertSpacing + 10); if (Items[index].TweenPosition < .5f) { g.DrawImage(bmpPunchIn, (int)((float)x * horzMultiple + 44), y * VertSpacing + 10); } else { g.DrawImage(bmpPunchOut, (int)((float)x * horzMultiple + 135), y * VertSpacing + 10); } } } else { g.DrawImage(thumbnailSize == ThumbnailSize.Big ? bmpBackgroundWide : bmpBackground, (int)((float)x * horzMultiple + 44), y * VertSpacing + 20); } if (index == selectedItem && !dragging && TransitionHighlighted && !multipleSelection) { g.DrawImage(TransHighlight, (int)((float)x * horzMultiple + 3), y * VertSpacing + 20); } Bitmap bmpTrans = null; switch (Items[index].Transition) { default: case TransitionType.Slew: bmpTrans = TransArrow; break; case TransitionType.CrossCut: bmpTrans = TransCut; break; case TransitionType.CrossFade: bmpTrans = transCrossFade; break; case TransitionType.FadeOut: bmpTrans = TransFadeOut; break; case TransitionType.FadeIn: bmpTrans = TransFadeIn; break; case TransitionType.FadeOutIn: bmpTrans = TransFadeOutIn; break; } g.DrawImage(bmpTrans, (int)((float)x * horzMultiple + 5), y * VertSpacing + 22); try { g.DrawImage(Items[index].Thumbnail, (int)((float)x * horzMultiple) + 46, y * VertSpacing + 23); g.DrawRectangle(Pens.Black, (int)((float)x * horzMultiple + 10) + 36, y * VertSpacing + 23, Items[index].Thumbnail.Width, Items[index].Thumbnail.Height); } // TODO FIX this! catch { } if (Items[index].MasterSlide) { g.DrawImage(bmpMasterMarker, (int)((float)x * horzMultiple + 46), y * VertSpacing + 20); } RectangleF rectTime = new RectangleF((float)x * horzMultiple + 47f, y * VertSpacing + 87, ThumbWidth - 10, 15); if (Items[index].Description != null) { g.DrawString(Items[index].Description, UiTools.StandardRegular, textBrush, rectf, UiTools.StringFormatThumbnails); } TimeSpan duration = Items[index].Duration; String durationString = String.Format("{0}:{1:00}.{2}", duration.Minutes, duration.Seconds, duration.Milliseconds / 10); g.DrawString(durationString, UiTools.StandardRegular, textBrush, rectTime, UiTools.StringFormatBottomCenter); if (index == this.dragDropItemLocation) { g.DrawImage(bmpDropInsertMarker, (int)((float)x * horzMultiple) + 34, (int)((float)y * VertSpacing) + 20); //g.DrawRectangle(Pens.Yellow, new Rectangle((int)((float)x * horzMultiple), (int)((float)y * VertSpacing + 1), 1, VertSpacing - 22)); } if (Properties.Settings.Default.ShowSlideNumbers) { RectangleF rectSlideNumber = new RectangleF((float)x * horzMultiple + 47f, y * VertSpacing + 7, ThumbWidth - 10, 15); g.DrawString(index.ToString(), UiTools.StandardRegular, textBrush, rectSlideNumber, UiTools.StringFormatBottomCenter); } index++; } if (index >= Items.Count) { break; } } }