示例#1
0
        private static bool TrySnappingToOperatorsConnectedBelow(OperatorWidget el, List <OperatorWidget> dragGroup)
        {
            var tgt = el as OperatorWidget;

            if (tgt == null)
            {
                return(false);
            }

            var op = (from opBelow in tgt.GetOpsConnectedToInputs()
                      where !dragGroup.Contains(opBelow) &&
                      !opBelow.CurrentlyDragged() &&
                      Math.Abs(el.Position.Y + CompositionGraphView.GRID_SIZE - opBelow.Position.Y) < VERTICAL_DISTANCE_SNAP_THRESHOLD &&
                      el.GetHorizontalOverlapWith(opBelow) > HORIZONTAL_OVERLAP_SNAP_THRESHOD
                      select opBelow).FirstOrDefault();

            if (op == null)
            {
                return(false);
            }

            double dx = el.Position.X - op.Position.X;

            el.Position = new Point(el.Position.X - ((dx + 0.5 * CompositionGraphView.GRID_SIZE) % CompositionGraphView.GRID_SIZE) + 0.5 * CompositionGraphView.GRID_SIZE,
                                    op.Position.Y - CompositionGraphView.GRID_SIZE);
            return(true);
        }
        /**
         * Note: It's interesting that this handler does not use the event properties but rather
         * directly accesses the sender's internal property to get a complete list of all selected elements.
         */
        public void SelectionChangedEventHandler(object sender, SelectionHandler.SelectionChangedEventArgs args)
        {
            var selectionHandler = sender as SelectionHandler;

            if (selectionHandler != null)
            {
                // Clear up all handlers
                foreach (var item in m_ObservedOperatorWidgets)
                {
                    OperatorWidget op = item as OperatorWidget;
                    if (op != null)
                    {
                        op.Operator.ModifiedEvent -= OperatorModifiedHandler;
                    }
                }
                m_FocusedCurves.Clear();
                m_ObservedOperatorWidgets.Clear();

                // Listen to changes of selected ops
                foreach (var item in selectionHandler.SelectedElements)
                {
                    var op = item as OperatorWidget;
                    if (op != null)
                    {
                        op.Operator.ModifiedEvent += OperatorModifiedHandler;
                        m_ObservedOperatorWidgets.Add(op);
                    }
                }

                //CustomCommands.FitCurveValueRangeCommand.Execute(null, this);
                ShowCurvesForSelectedOperators();
                FitValueRange();
            }
        }
示例#3
0
        public TimeClipViewModel(OperatorWidget op)
        {
            OperatorWidget = op;
            m_TimeClip     = op.Operator.InternalParts[0].Func as ITimeClip;

            op.Operator.InternalParts[0].ChangedEvent += ForwardChangedNotification;

            BindingOperations.SetBinding(op, OperatorWidget.IsSelectedProperty, new Binding("IsSelected")
            {
                Source = this, Mode = BindingMode.TwoWay
            });
        }
示例#4
0
        private static void AddSnappedNeighboursToPool(List <OperatorWidget> pool, OperatorWidget el)
        {
            pool.Add(el);
            var parentsAndChildren = new List <OperatorWidget>();

            parentsAndChildren.AddRange((el as OperatorWidget).GetOperatorsSnappedAbove());
            parentsAndChildren.AddRange((el as OperatorWidget).GetOperatorsSnappedBelow());

            foreach (var opWi in parentsAndChildren)
            {
                if (!pool.Contains(opWi))
                {
                    AddSnappedNeighboursToPool(pool, opWi);
                }
            }
        }
示例#5
0
        public AnnotationViewModel(OperatorWidget opWidget)
        {
            OperatorWidget = opWidget;
            _operator      = OperatorWidget.Operator;
            _operatorFunc  = _operator.InternalParts[0].Func as IAnnotation;
            Position       = _operator.Position;
            Width          = _operator.Width;

            _operator.InternalParts[0].ChangedEvent += ForwardChangedNotification;
            _operator.PositionChangedEvent          += Operator_PositionChangedEvent;
            _operator.WidthChangedEvent             += Operator_WidthChangedEvent;

            BindingOperations.SetBinding(opWidget, OperatorWidget.IsSelectedProperty, new Binding("IsSelected")
            {
                Source = this, Mode = BindingMode.TwoWay
            });
        }
示例#6
0
        public TimeMarkerViewModel(OperatorWidget op)
        {
            OperatorWidget = op;
            _TimeMarker    = op.Operator.InternalParts[0].Func as ITimeMarker;

            //FixMe: Binding the ForwardChangedNotification to the ChangedEvent is extremely slow.
            // Additionally it's unclear what would be the reason for triggering an update of the operator's parameters
            // depending on it's input.
            //op.Operator.InternalParts[0].ChangedEvent += ForwardChangedNotification;

            //FixMe: Binding to magic numbers of the TimeClip parameters is evil.
            op.Operator.Inputs[0].ChangedEvent += (o, a) => ForwardChangedNotification();
            op.Operator.Inputs[1].ChangedEvent += (o, a) => ForwardChangedNotification();
            op.Operator.Inputs[2].ChangedEvent += (o, a) => ForwardChangedNotification();
            op.Operator.Inputs[3].ChangedEvent += (o, a) => ForwardChangedNotification();
            op.Operator.Inputs[4].ChangedEvent += (o, a) => ForwardChangedNotification();
            op.Operator.PropertyChanged        += (o, a) => ForwardChangedNotification();
            BindingOperations.SetBinding(op, OperatorWidget.IsSelectedProperty, new Binding("IsSelected")
            {
                Source = this, Mode = BindingMode.TwoWay
            });
        }
示例#7
0
 public OperatorSnappingHelper(OperatorWidget movedOperator)
 {
     MovingOperator = movedOperator;
 }