public FsmGraphView(FsmGraphObject fsmGraphObject) { VisualElementExtensions.AddManipulator(this, new ContentDragger()); VisualElementExtensions.AddManipulator(this, new SelectionDragger()); style.flexGrow = 1f; foreach (StateInstanceNode node in fsmGraphObject.GetNodes()) { StateInstanceNodeView nodeView = new StateInstanceNodeView(node); nodeView.SetPosition(FindPosition(nodeView)); nodeViews.Add(node.stateInstance.name, nodeView); AddElement(nodeView); } foreach (TransitionInstanceEdge transitionEdge in fsmGraphObject.edges) { TransitionEdgeView transitionView = new TransitionEdgeView(transitionEdge) { input = nodeViews[transitionEdge.transitionInstance.originState].inputPort, output = nodeViews[transitionEdge.transitionInstance.targetState].outputPort }; AddElement(transitionView); } }
public static Point[] GetTouches(MotionEvent.PointerCoords[] pointerCoords, Android.Views.View sourceView, Listener listener) { Point delta = Point.Zero; if (listener?.Element != null && Xamarin.Forms.Platform.Android.Platform.GetRenderer(listener?.Element) is Xamarin.Forms.Platform.Android.IVisualElementRenderer renderer && renderer.View != sourceView ) { var listenerViewLocation = listener != null ? VisualElementExtensions.LocationInWindowCoord(listener.Element) : Point.Zero; var touchViewLocation = AndroidViewExtensions.LocationInFormsCoord(sourceView); delta = touchViewLocation.Subtract(listenerViewLocation); //System.Diagnostics.Debug.WriteLine("vl["+listenerViewLocation.ToString("N2")+"] ["+touchViewLocation.ToString("+N2+")+"]"); } var pointerCount = pointerCoords.Length; var array = new Point[pointerCount]; for (int i = 0; i < pointerCount; i++) { array[i] = new Point(pointerCoords[i].X + delta.X, pointerCoords[i].Y + delta.Y); } return(array); }
void CreatePlacemat(DropdownMenuAction a) { Vector2 pos = a.eventInfo.localMousePosition; Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); CreatePlacemat(new Rect(localPos.x, localPos.y, 200, 200)); }
private void OnScroll(WheelEvent e) { Vector2 zoomCenter = VisualElementExtensions.ChangeCoordinatesTo(base.target, this.targetElement, e.localMousePosition); float zoomScale = 1f - e.delta.y * zoomStep; this.Zoom(zoomCenter, zoomScale); e.StopPropagation(); }
//!Ustawia parametry okna po jego aktywacji. void OnEnable() { view = new DialogNodeView(); VisualElementExtensions.StretchToParentSize(view); rootVisualElement.Add(view); createMenubar(); createMinimap(); }
public void SetupGUI() { VisualElement rootVisualContainer = new VisualElement(); this.m_ZoomManipulator = new ZoomManipulator(rootVisualContainer, this); VisualElementExtensions.AddManipulator(rootVisualContainer, m_ZoomManipulator); rootVisualContainer.RegisterCallback <WheelEvent>((x) => { Debug.Log(x); rootVisualContainer.HandleEvent(x); }); }
public AndroidSwipeEventArgs(MotionEvent current, View view, Direction direction, Listener listener) { Listener = listener; Cancelled = current.Action == MotionEventActions.Cancel; ElementPosition = VisualElementExtensions.BoundsInWindowCoord(listener.Element); ElementTouches = AndroidEventArgsHelper.GetTouches(current, view, listener); //WindowTouches = AndroidEventArgsHelper.GetTouches(current, view, null); WindowTouches = AndroidEventArgsHelper.GetRawTouches(current); Direction = direction; }
public AndroidPinchEventArgs(MotionEvent current, MotionEvent.PointerCoords[] coords, PinchEventArgs previous, View view, Listener listener) { Listener = listener; Cancelled = (current.Action == MotionEventActions.Cancel); ElementPosition = VisualElementExtensions.BoundsInWindowCoord(listener.Element); ElementTouches = AndroidEventArgsHelper.GetTouches(coords, previous, view, listener); WindowTouches = AndroidEventArgsHelper.GetTouches(coords, previous, view, null); //WindowTouches = AndroidEventArgsHelper.GetRawTouches(current); CalculateScales(previous); }
public AndroidTapEventArgs(MotionEvent current, View view, int numberOfTaps, Listener listener) { Listener = listener; Cancelled = (current.Action == MotionEventActions.Cancel); ElementPosition = VisualElementExtensions.BoundsInWindowCoord(listener.Element); ElementTouches = AndroidEventArgsHelper.GetTouches(current, view, listener); //WindowTouches = AndroidEventArgsHelper.GetTouches(current, view, null); WindowTouches = AndroidEventArgsHelper.GetRawTouches(current); NumberOfTaps = numberOfTaps; }
public DialogNodeView() { VisualElementExtensions.AddManipulator(this, new ContentDragger()); VisualElementExtensions.AddManipulator(this, new ContentZoomer()); VisualElementExtensions.AddManipulator(this, new SelectionDragger()); VisualElementExtensions.AddManipulator(this, new RectangleSelector()); VisualElementExtensions.AddManipulator(this, new EdgeManipulator()); createRootNode(); }
public AndroidPanEventArgs(MotionEvent previous, MotionEvent current, BaseGestureEventArgs prevArgs, Android.Views.View view, Listener listener) { Listener = listener; Cancelled = (current.Action == MotionEventActions.Cancel); ElementPosition = VisualElementExtensions.BoundsInWindowCoord(listener.Element); ElementTouches = AndroidEventArgsHelper.GetTouches(current, view, listener); //WindowTouches = AndroidEventArgsHelper.GetTouches(current, view, null); WindowTouches = AndroidEventArgsHelper.GetRawTouches(current); CalculateDistances(prevArgs); Velocity = GetVelocity(previous, current); }
void LoadContent() { _currentView = Element.Content; IVisualElementRenderer visualElementRenderer = null; if (_currentView != null) { visualElementRenderer = VisualElementExtensions.GetOrCreateRenderer(_currentView); } Control.SetContent(visualElementRenderer != null ? visualElementRenderer.ContainerElement : null); }
protected void OnMouseDown(MouseDownEvent e) { if (base.CanStartManipulation(e)) { this.m_Start = (this.m_Last = e.localMousePosition); this.m_ZoomCenter = VisualElementExtensions.ChangeCoordinatesTo(base.target, this.m_GraphUI, this.m_Start); this.m_Active = true; MouseCaptureController.TakeMouseCapture(base.target); e.StopPropagation(); } Debug.Log(e); }
private GraphElement CreateGraphMathStackNode(Vector2 pos) { var stackNode = ScriptableObject.CreateInstance <MathStackNode>(); Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); stackNode.name = "Stack"; stackNode.m_Position = localPos; m_SimpleGraphViewWindow.AddNode(stackNode); return(m_SimpleGraphViewWindow.CreateNode(stackNode)); }
private void CreateGroupNode(DropdownMenuAction a) { Vector2 pos = a.eventInfo.localMousePosition; var groupNode = ScriptableObject.CreateInstance <MathGroupNode>(); Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); groupNode.m_Title = "New Group"; groupNode.m_Position = localPos; m_SimpleGraphViewWindow.AddNode(groupNode); GraphElement graphGroup = m_SimpleGraphViewWindow.CreateNode(groupNode); AddElement(graphGroup); }
public override void BuildContextualMenu(ContextualMenuPopulateEvent evt) { foreach (var t in Enum.GetValues(typeof(ExpressionType))) { var type = (ExpressionType)t; if (type == ExpressionType.Undefined || type == ExpressionType.Results) { continue; } evt.menu.AppendAction($"Create {type}", menuAction => { var n = AddNode(type); var localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, menuAction.eventInfo.localMousePosition); n.SetPosition(new Rect(localPos, n.GetPosition().size)); }); } evt.menu.AppendSeparator(); base.BuildContextualMenu(evt); }
public AndroidLongPressEventArgs(MotionEvent start, MotionEvent end, View view, Listener listener) { MotionEvent current = end ?? start; Listener = listener; Cancelled = current.Action == MotionEventActions.Cancel; ElementPosition = VisualElementExtensions.BoundsInWindowCoord(listener.Element); ElementTouches = AndroidEventArgsHelper.GetTouches(current, view, listener); //WindowTouches = AndroidEventArgsHelper.GetTouches(current, view, null); WindowTouches = AndroidEventArgsHelper.GetRawTouches(current); if (start != null && end != null) { Duration = end.EventTime - start.EventTime; } else { Duration = 500; } }
private void CreateStickyNote(DropdownMenuAction a) { Vector2 pos = a.eventInfo.localMousePosition; var stickyNote = ScriptableObject.CreateInstance <MathStickyNote>(); Vector2 localPos = VisualElementExtensions.ChangeCoordinatesTo(this, contentViewContainer, pos); stickyNote.title = "New Title"; stickyNote.contents = "Type something here"; stickyNote.position = new Rect(localPos, new Vector2(200, 180)); m_SimpleGraphViewWindow.AddStickyNote(stickyNote); var simpleStickyNote = new SimpleStickyNote(); simpleStickyNote.model = stickyNote; simpleStickyNote.userData = stickyNote; AddElement(simpleStickyNote); }