Ejemplo n.º 1
0
        public Rect GetRangeForInputConnectionLine(OperatorPart input, int multiInputIndex, bool insertConnection = false)
        {
            var zones = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(this);

            OperatorWidgetInputZone matchingZone = null;

            foreach (var zone in zones)
            {
                if (zone.Input == input && zone.MultiInputIndex == multiInputIndex)
                {
                    if (!insertConnection && zone.InsertAtMultiInputIndex)
                    {
                        continue;
                    }

                    matchingZone = zone;
                    break;
                }
            }

            // Animations on non-relevant paraemters don't have a matching zone...
            if (matchingZone == null)
            {
                return(new Rect(0, 0, 0, 0));
            }

            double minX = matchingZone.LeftPosition;
            double maxX = matchingZone.LeftPosition + matchingZone.Width;

            return(new Rect(minX, Height, maxX - minX, 0));
        }
Ejemplo n.º 2
0
        public void GetAndDrawInputZones()
        {
            var inputZonesForDrag = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(this);

            UpdateInputZonesUIFromDescription(inputZonesForDrag);
            UpdateInputRanges(inputZonesForDrag);
        }
Ejemplo n.º 3
0
        private void XOperatorWidgetThumb_Drop(object sender, DragEventArgs e)
        {
            var mousePosition     = e.GetPosition(this);
            var inputZonesForDrag = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(this);
            var zoneBelowMouse    = OperatorWidgetInputZoneManager.FindZoneBelowMouse(inputZonesForDrag, mousePosition);

            if (zoneBelowMouse != null)
            {
                CV.CompositionGraphView.ConnectionDragHelper.Stop(new Vector(0, 0), zoneBelowMouse);
            }
            e.Handled = true;
        }
Ejemplo n.º 4
0
        public OperatorWidget(Operator op)
        {
            Operator = op;
            _outputs = Operator.Outputs;
            _inputs  = Operator.Inputs;

            InitializeComponent();
            CreateBindingsToOperator();

            var outputFunctions = from output in _outputs
                                  where output.Func is Utilities.ValueFunction
                                  select output.Func as Utilities.ValueFunction;

            foreach (var func in outputFunctions)
            {
                func.EvaluatedEvent += OperatorOutputFunction_EvaluatedHandler;
            }

            _snapHandler = new OperatorSnappingHelper(this);

            Height = CompositionGraphView.GRID_SIZE;
            Width  = Operator.Width;

            var inputZones = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(this);

            UpdateInputRanges(inputZones);
            UpdateColors();

            UpdateOutputNoses();
            int outputIdx = 0;

            foreach (Path nosePath in XOutputThumbGrid.Children.OfType <Path>())
            {
                nosePath.Fill = new SolidColorBrush(UIHelper.ColorFromType(Operator.Outputs[outputIdx].Type));
                nosePath.Fill.Freeze();
                ++outputIdx;
            }

            if (!op.Visible)
            {
                Opacity          = 0;
                IsHitTestVisible = false;
            }
        }
Ejemplo n.º 5
0
        /**
         * This function is called by IConnectionTargets when
         * the end of a connection is dragged over them.
         *
         * To "snap" valid connections, we save the zone so the
         * GiveFeedbackHandler can use its position.
         */
        public void HandleDragOverEvent(DragEventArgs e, IConnectionLineTarget targetWidget)
        {
            e.Effects = DragDropEffects.None;
            e.Handled = true;

            var connectionStartOutput = e.Data.GetData(CONNECTION_LINE_OUTPUT_IDENTIFIER) as OperatorPart;

            if (connectionStartOutput == null)
            {
                return;  // Skip non-connection drop data
            }
            // We can't use Mouse.GetPosition() also see
            // http://msdn.microsoft.com/en-us/library/system.windows.input.mouse.getposition(v=vs.110).aspx
            var mousePosition     = e.GetPosition(targetWidget as UIElement);
            var inputZonesForDrag = OperatorWidgetInputZoneManager.ComputeInputZonesForOp(targetWidget);
            var zoneBelowMouse    = OperatorWidgetInputZoneManager.FindZoneBelowMouse(inputZonesForDrag, mousePosition);

            if (zoneBelowMouse != null)
            {
                zoneBelowMouse.IsBelowMouse = true;
                _snappedToValidInput        = zoneBelowMouse.Input.Type == connectionStartOutput.Type ||
                                              zoneBelowMouse.Input.Type == FunctionType.Generic;

                if (_snappedToValidInput)
                {
                    e.Effects             = DragDropEffects.Copy;
                    _snappedPointOnCanvas = targetWidget.PositionOnCanvas + new Vector(zoneBelowMouse.LeftPosition + 0.5 * zoneBelowMouse.Width, targetWidget.Height);
                }
            }

            if (mousePosition == _lastDragOverPosition)
            {
                return;
            }

            _lastDragOverPosition = mousePosition;
            targetWidget.UpdateInputZonesUIFromDescription(inputZonesForDrag);
        }