示例#1
0
        public DeviceViewer(Device device)
        {
            InitializeComponent();

            TitleText.Text = device.Name;

            _device        = device;
            _device.Viewer = this;
            Deselect();

            DeviceContextMenu = (ApolloContextMenu)this.Resources["DeviceContextMenu"];
            GroupContextMenu  = (ApolloContextMenu)this.Resources["GroupContextMenu"];
            ChokeContextMenu  = (ApolloContextMenu)this.Resources["ChokeContextMenu"];

            this.AddHandler(DragDrop.DropEvent, Drop);
            this.AddHandler(DragDrop.DragOverEvent, DragOver);

            SpecificViewer = GetSpecificViewer(this, _device);

            if (SpecificViewer != null)
            {
                this.Get <Grid>("Contents").Children.Add(SpecificViewer);
            }

            SetEnabled();
        }
示例#2
0
        public void DragFailed(PointerPressedEventArgs e)
        {
            PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind;

            if (MouseButton == PointerUpdateKind.RightButtonPressed)
            {
                ApolloContextMenu menu      = DeviceContextMenu;
                List <ISelect>    selection = Track.Get(_device)?.Window?.Selection.Selection;

                if (selection.Count == 1)
                {
                    if (selection[0] is Group group && group.Count == 1)
                    {
                        menu = GroupContextMenu;
                    }

                    else if (selection[0] is Choke)
                    {
                        menu = ChokeContextMenu;
                    }
                }

                DeviceMute.Header = GroupMute.Header = ChokeMute.Header = ((Device)selection.First()).Enabled? "Mute" : "Unmute";

                menu.Open(Draggable);
            }
示例#3
0
        public async void Drag(object sender, PointerPressedEventArgs e)
        {
            PointerUpdateKind MouseButton = e.GetCurrentPoint(this).Properties.PointerUpdateKind;

            if (!selected)
            {
                Select(e);
            }

            DataObject dragData = new DataObject();

            dragData.Set("device", Track.Get(_device)?.Window?.Selection.Selection);

            App.Dragging = true;
            DragDropEffects result = await DragDrop.DoDragDrop(e, dragData, DragDropEffects.Move);

            App.Dragging = false;

            if (result == DragDropEffects.None)
            {
                if (selected)
                {
                    Select(e);
                }

                if (MouseButton == PointerUpdateKind.RightButtonPressed)
                {
                    ApolloContextMenu menu      = DeviceContextMenu;
                    List <ISelect>    selection = Track.Get(_device)?.Window?.Selection.Selection;

                    if (selection.Count == 1)
                    {
                        if (selection[0] is Group group && group.Count == 1)
                        {
                            menu = GroupContextMenu;
                        }

                        else if (selection[0] is Choke)
                        {
                            menu = ChokeContextMenu;
                        }
                    }

                    DeviceMute.Header = GroupMute.Header = ChokeMute.Header = ((Device)selection.First()).Enabled? "Mute" : "Unmute";

                    menu.Open(Draggable);
                }
                else if (MouseButton == PointerUpdateKind.LeftButtonPressed && e.ClickCount == 2)
                {
                    _device.Collapsed = !_device.Collapsed;
                    DeviceCollapsed?.Invoke(_device.ParentIndex.Value);
                }
            }
示例#4
0
        protected virtual void Unloaded(object sender, VisualTreeAttachmentEventArgs e)
        {
            ResetEvents();

            SpecificViewer = null;
            _device.Viewer = null;
            _device        = null;

            DeviceContextMenu = GroupContextMenu = ChokeContextMenu = null;

            this.RemoveHandler(DragDrop.DropEvent, Drop);
            this.RemoveHandler(DragDrop.DragOverEvent, DragOver);
        }
示例#5
0
        protected virtual void Unloaded(object sender, VisualTreeAttachmentEventArgs e)
        {
            ResetEvents();

            SpecificViewer = null;
            _device.Viewer = null;
            _device        = null;

            DeviceContextMenu = GroupContextMenu = ChokeContextMenu = null;

            DragDrop.Dispose();
            DragDrop = null;
        }
示例#6
0
 void ContextMenu_Action(ApolloContextMenu sender, string action) =>
 Device_Action(action, sender == (ApolloContextMenu)this.Resources["DeviceContextMenuAfter"]);