Пример #1
0
        void  selectedEntry_DragMoved(object sender, MouseEventArgs e)
        {
            VideoPanelEntry         entry         = sender as VideoPanelEntry;
            IEnumerable <UIElement> hitTestResult = VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition((Application.Current.RootVisual as Page).VideoArea), (Application.Current.RootVisual as Page).VideoArea);
            bool _foundVideoPanelEntry            = false;

            foreach (UIElement hitElement in hitTestResult)
            {
                if ((!_foundVideoPanelEntry) && (hitElement.Equals(entry)))
                {
                    _foundVideoPanelEntry = true;
                }
                else
                {
                    if (hitElement.Equals(this))
                    {
                        entry.DragAndDropState = VideoPanelEntryDragAndDropState.NoDrop;
                        break;
                    }

                    if (hitElement is VideoPlayer)
                    {
                        entry.DragAndDropState = VideoPanelEntryDragAndDropState.Move;
                        break;
                    }

                    // if we get to the VideoArea Canvas, then nothing else was hit
                    if (hitElement.Equals((Application.Current.RootVisual as Page).VideoArea))
                    {
                        entry.DragAndDropState = VideoPanelEntryDragAndDropState.Add;
                        break;
                    }
                }
            }
        }
Пример #2
0
 private void AddEntry(VideoPanelEntry newEntry)
 {
     newEntry.DragStarted += new EventHandler(newEntry_DragStarted);
     Canvas.SetLeft(newEntry, Math.Max(this.Width, entryContainer.Children.Count * (100 + SpaceBetweenEntries)));
     entryContainer.Children.Add(newEntry);
     UpdateLayoutInternal();
 }
Пример #3
0
        void newEntry_DragStarted(object sender, EventArgs e)
        {
            VideoPanelEntry  selectedEntry = sender as VideoPanelEntry;
            GeneralTransform transform     = selectedEntry.TransformToVisual((Application.Current.RootVisual as Page).VideoArea);
            Point            newOffset     = transform.Transform(new Point(0, 0));

            entryContainer.Children.Remove(selectedEntry);

            selectedEntry.DragStarted -= newEntry_DragStarted;
            selectedEntry.DragMoved   += new MouseEventHandler(selectedEntry_DragMoved);
            selectedEntry.Dropped     += new MouseButtonEventHandler(selectedEntry_Dropped);

            (Application.Current.RootVisual as Page).VideoArea.Children.Add(selectedEntry);
            Canvas.SetLeft(selectedEntry, newOffset.X);
            Canvas.SetTop(selectedEntry, newOffset.Y);
            UpdateLayoutInternal();
        }
Пример #4
0
        void selectedEntry_Dropped(object sender, MouseButtonEventArgs e)
        {
            VideoPanelEntry         entry         = sender as VideoPanelEntry;
            IEnumerable <UIElement> hitTestResult = VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition((Application.Current.RootVisual as Page).VideoArea), (Application.Current.RootVisual as Page).VideoArea);
            bool _foundVideoPanelEntry            = false;

            foreach (UIElement hitElement in hitTestResult)
            {
                if ((!_foundVideoPanelEntry) && (hitElement.Equals(entry)))
                {
                    _foundVideoPanelEntry = true;
                }
                else
                {
                    if (hitElement.Equals(this))
                    {
                        break;
                    }

                    if (hitElement is VideoPlayer)
                    {
                        (hitElement as VideoPlayer).Source = entry.VideoUri;
                        break;
                    }

                    // if we get to the VideoArea Canvas, then nothing else was hit
                    if (hitElement.Equals((Application.Current.RootVisual as Page).VideoArea))
                    {
                        if (EntryDropped != null)
                        {
                            EntryDropped(this, new VideoPanelEventArgs(entry.VideoUri, e));
                        }

                        break;
                    }
                }
            }

            (Application.Current.RootVisual as Page).VideoArea.Children.Remove(entry);
        }