public void AddText(string text) { Text = Text.Insert(CursorPosition, text); CursorPosition += text.Length; OnTextChange?.Invoke(this); OnPositionChange?.Invoke(this); }
private void PositionWidget_OnPositionChange(Vector3 newpos, Vector3 oldpos) { DefaultWidget.Position = newpos; RotationWidget.Position = newpos; ScaleWidget.Position = newpos; OnPositionChange?.Invoke(newpos, oldpos); }
private void Progress_OnPositionChange(int pos, int dur, int window) { if (mediaSource != null) { //current media cursor if (Resources.Configuration.LayoutDirection == Android.Views.LayoutDirection.Rtl) { cursor.TranslationX = track.MeasuredWidth + Utils.dp2px(Context, 34.5f) - (float)(((double)pos / dur) * track.MeasuredWidth); } else { cursor.TranslationX = (float)(((double)pos / dur) * track.MeasuredWidth); } FindViewById <TextView>(Resource.Id.lefttime).Text = TimeSpan.FromMilliseconds(pos).ToString(@"mm\:ss"); if (_player.Duration > 0) { FindViewById <TextView>(Resource.Id.righttime).Text = TimeSpan.FromMilliseconds(_player.Duration).ToString(@"mm\:ss"); } //Console.WriteLine(window); if (currentmode == PLAYBACK_MODE.TRIM_CLIP) { OnPositionChange?.Invoke((int)Math.Min(pos - InPoint.TotalMilliseconds, OutPoint.TotalMilliseconds), dur, window, currentmode); } else { OnPositionChange?.Invoke(pos, dur, window, currentmode); } } }
/// <summary> /// Fit all elements in the area. /// </summary> public virtual void Fit() { // If there are no object nothink to do. if (Objects.Count == 0) { return; } // Sort all elements for height. Objects = Objects.OrderByDescending(X => X.Size.Height).ToList(); // Add first object. pTree.Size = Objects[0].Size + Spacing; Block Node; // Foreach object try to fit it. foreach (T B in Objects) { // If we found the space for fit this object if ((Node = FindNode(pTree, B.Size + Spacing)) != null) { // Split the current node and set the new position Node = SplitNode(Node, B.Size + Spacing); if (B.Position != Node.Position) { OnPositionChange?.Invoke(this, B); } B.Position = Node.Position; } else { // Else grow the atlas Node = GrowNode(B.Size + Spacing); // If we can't grow the atlas, this item can't be added if (Node == null) { if (!NotFitted.Contains(B)) { NotFitted.Add(B); } OnElementNotFit?.Invoke(this, B); continue; } if (B.Position != Node.Position) { OnPositionChange?.Invoke(this, B); } // Else space found! B.Position = Node.Position; } } }
private void OnPointerMove(PointerEventArgs e) { if (DragMode) { if (e.Buttons == 1) { int NewPosition = 0; int NewPosition2 = 0; if (bsSettings.IsDiagonal) { NewPosition = (int)e.ClientX; NewPosition2 = (int)e.ClientY; if (bSplitter.PreviousPosition != NewPosition || bSplitter.PreviousPosition2 != NewPosition2) { OnDiagonalPositionChange?.Invoke(bsSettings.index, NewPosition - bSplitter.PreviousPosition, NewPosition2 - bSplitter.PreviousPosition2); bSplitter.PreviousPosition = NewPosition; bSplitter.PreviousPosition2 = NewPosition2; } } else { if (bsSettings.VerticalOrHorizontal) { NewPosition = (int)e.ClientY; NewPosition2 = (int)e.ClientX; } else { NewPosition = (int)e.ClientX; NewPosition2 = (int)e.ClientY; } if (Math.Abs(bSplitter.PreviousPosition2 - NewPosition2) < 100) { if (bSplitter.PreviousPosition != NewPosition) { OnPositionChange?.Invoke(bsSettings.VerticalOrHorizontal, bsSettings.index, NewPosition - bSplitter.PreviousPosition); bSplitter.PreviousPosition = NewPosition; } } //else //{ // //BsJsInterop.StopDrag(bSplitter.bsbSettings.ID); //} } } } }
public void SetPosition(Position p, bool taken = false) { Position = p; Deselect(); transform.position = new Vector3(7 - p.Col, taken ? -0.5f : 0f, p.Row); OnPositionChange?.Invoke(p); }
public void Backspace() { if (CursorPosition > 0) { Text = Text.Remove(CursorPosition - 1, 1); CursorPosition -= 1; OnTextChange?.Invoke(this); OnPositionChange?.Invoke(this); } }
public virtual void ProcessFixedUpdate(float fixedDeltaTime) { if (GameTransform.hasChanged) { OnPositionChange?.Invoke(GameTransform.position); GameTransform.hasChanged = false; } effectController.ProcessFixedUpdate(fixedDeltaTime); StatHolder.ProcessFixedUpdate(fixedDeltaTime); }
public void Translate(Vector2 normalizedDestination) { _gameObject.transform.Translate(normalizedDestination * (_speed * Time.deltaTime)); VelocityHandler?.Invoke(normalizedDestination, FacingDirection); Node currentNode = Utils.NodeAt(Utils.ToVector2Int(WorldPosition)); if (currentNode.IsTraversable) { OnGridPositionChange?.Invoke(_lastTraversablePosition, currentNode.Position); _lastTraversablePosition = currentNode.Position; } OnPositionChange?.Invoke(WorldPosition); }
public void Initialize() { _locationAnchorMinX = _pagesContainer.anchorMin.x; _locationAnchorMaxX = _pagesContainer.anchorMax.x; _pageCount = _pagesContainer.childCount; _indicators = _indicatorsContainer.GetComponentsInChildren <CarouselIndicator>(); foreach (var indicator in _indicators) { indicator.SetTransparency(0); } _indicators[_currentPage].SetTransparency(1); OnPositionChange?.Invoke(_currentPage); }
private IEnumerator SmoothMove(float startAnchorMinX, float startAnchorMaxX, float seconds) { var t = 0f; while (t <= 1.0f) { t += Time.deltaTime / seconds; _pagesContainer.anchorMin = new Vector2(Mathf.Lerp(startAnchorMinX, _locationAnchorMinX, t), _pagesContainer.anchorMin.y); _pagesContainer.anchorMax = new Vector2(Mathf.Lerp(startAnchorMaxX, _locationAnchorMaxX, t), _pagesContainer.anchorMax.y); OnPositionChange?.Invoke(-_pagesContainer.anchorMin.x); yield return(null); } }
private void ChangePos(int pos) { if (CursorPosition != pos) { if (pos > Text.Length) { pos = Text.Length; } if (pos < 0) { pos = 0; } CursorPosition = pos; OnPositionChange?.Invoke(this); } }
public void OnDrag(PointerEventData eventData) { var difference = (eventData.pressPosition.x - eventData.position.x) / PageWidth; _pagesContainer.anchorMin = new Vector2(_locationAnchorMinX - difference, _pagesContainer.anchorMin.y); _pagesContainer.anchorMax = new Vector2(_locationAnchorMaxX - difference, _pagesContainer.anchorMax.y); if (difference > 0 && _currentPage < _pageCount - 1) { _indicators[_currentPage].SetTransparency(1 - difference); _indicators[_currentPage + 1].SetTransparency(difference); } else if (difference < 0 && _currentPage > 0) { _indicators[_currentPage].SetTransparency(1 + difference); _indicators[_currentPage - 1].SetTransparency(-difference); } OnPositionChange?.Invoke(-_pagesContainer.anchorMin.x); }
private void DoUpdate() { PostDelayed(() => { if (mediaisprepared && !IsTitle) { try { //Console.WriteLine("Pos: " + mp.CurrentPosition); OnPositionChange?.Invoke(mp.CurrentPosition, mp.Duration); } catch { //illagal state -- ignore } } //check for outpoint try { //keep on going... if (mediaisprepared && mp.IsPlaying) { DoUpdate(); } else if (IsTitle) { OnPositionChange?.Invoke(TitlePosition, OutPoint); DoUpdate(); } } catch (Exception ed) { //video error Console.WriteLine(ed); } }, 200); }
private static void ProcessScannerOutput(object sender, string datagram) { var sendDatagram = true; switch (datagram[0]) { case 'M': ChangeMoveState(datagram); break; case 'C': LogMessage("Received comment «" + datagram.Substring(1) + "»"); break; case 'K': // All is well, don't interpret it break; case 'E': LogMessage("The scanner couldn't understand the last command!"); break; case 'D': // Debug message, don't interpret it break; case 'P': Regex stopFormat = new Regex(@"^.([\-0-9]+),([\-0-9]+)$"); var match = stopFormat.Match(datagram); if (!match.Success) { LogMessage("Failed parsing the stop datagram: " + datagram); break; } RawPos.X = int.Parse(match.Groups[1].Value); RawPos.Y = int.Parse(match.Groups[2].Value); OnPositionChange?.Invoke(null, RawPos - new Size(Origin)); if (IgnorePositionInLogs) { sendDatagram = false; } break; case 'I': if (datagram.Equals(RawComms.ISTARTED_DATAGRAM)) { LogMessage("The scanner started."); } else { LogMessage("Unknown information datagram: " + datagram); } break; default: LogMessage("Failed interpreting the scanner's output: «" + datagram + "»"); break; } if (sendDatagram) { OnRawScannerOutput?.Invoke(null, datagram); } }
public static void ResetOrigin() { Origin = RawPos; OnPositionChange?.Invoke(null, new Point(0, 0)); }
public void PositionChanged(Vector3 pos) { OnPositionChange?.Invoke(pos); }
public override void Update(Camera cam) { if (!Visible) { return; } var ori = ObjectSpace ? Rotation : Quaternion.Identity; Vector3 xdir = Vector3.UnitX; Vector3 ydir = Vector3.UnitY; Vector3 zdir = Vector3.UnitZ; Vector3[] axes = { xdir, ydir, zdir }; Vector3[] sides1 = { ydir, zdir, xdir }; Vector3[] sides2 = { zdir, xdir, ydir }; WidgetAxis[] sideax1 = { WidgetAxis.Y, WidgetAxis.Z, WidgetAxis.X }; WidgetAxis[] sideax2 = { WidgetAxis.Z, WidgetAxis.X, WidgetAxis.Y }; Quaternion iori = Quaternion.Invert(ori); Vector3 camrel = iori.Multiply(Position - cam.Position); Vector3 cdir = Vector3.Normalize(camrel); Ray ray = cam.MouseRay; ray.Position = iori.Multiply(ray.Position); ray.Direction = iori.Multiply(ray.Direction); float dist = camrel.Length(); float size = GetWorldSize(Size, dist, cam); float linestart = 0.2f * size; float lineend = 1.0f * size; float sideval = 0.4f * size; float arrowstart = 1.0f * size; float arrowend = 1.33f * size; float arrowrad = 0.06f * size; float axhitrad = 0.07f * size; float axhitstart = 0.2f * size; float axhitend = 1.33f * size; float sidehitend = 0.5f * size; float sidehitstart = 0.25f * size; float allhitrad = 0.07f * size; //test for single and double axes hits BoundingBox bb = new BoundingBox(); BoundingBox bb2 = new BoundingBox(); float hitd = float.MaxValue; float d, d2; WidgetAxis hitax = WidgetAxis.None; for (int i = 0; i < 3; i++) { WidgetAxis ax = (WidgetAxis)(1 << i); Vector3 s = sides1[i] * axhitrad + sides2[i] * axhitrad; bb.Minimum = camrel - s + axes[i] * axhitstart; bb.Maximum = camrel + s + axes[i] * axhitend; if (ray.Intersects(ref bb, out d)) //single axis { if (d < hitd) { hitd = d; hitax = ax; } } for (int n = i + 1; n < 3; n++) { //double axis hit test - don't hit if in the central area (L shape hit area) WidgetAxis ax2 = (WidgetAxis)(1 << n); bb.Minimum = camrel; bb.Maximum = camrel + axes[i] * sidehitend + axes[n] * sidehitend; bb2.Minimum = camrel; bb2.Maximum = camrel + axes[i] * sidehitstart + axes[n] * sidehitstart; if (ray.Intersects(ref bb, out d) && !ray.Intersects(ref bb2, out d2)) { if (d < hitd) { hitd = d; hitax = ax | ax2; } } } } //small box at the center for all axes hit. Vector3 ss = (axes[0] + axes[1] + axes[2]) * allhitrad; bb.Minimum = camrel - ss; bb.Maximum = camrel + ss; if (ray.Intersects(ref bb, out d)) { if (d < hitd) { hitd = d; hitax = WidgetAxis.XYZ; } } MousedAxis = hitax; if (IsDragging && !WasDragging) { //drag start. mark the start vector and axes DraggedAxis = MousedAxis; DragStartPosition = Position; DraggedAxisDir = axes[0]; DraggedAxisSideDir = axes[1]; switch (DraggedAxis) { case WidgetAxis.XZ: DraggedAxisSideDir = axes[2]; break; case WidgetAxis.YZ: DraggedAxisDir = axes[1]; DraggedAxisSideDir = axes[2]; break; case WidgetAxis.Y: DraggedAxisDir = axes[1]; break; case WidgetAxis.Z: DraggedAxisDir = axes[2]; break; } switch (DraggedAxis) //find the best second axis to use, for single axis motion only. { case WidgetAxis.X: case WidgetAxis.Y: case WidgetAxis.Z: int curax = GetAxisIndex(DraggedAxis); int minax = 0; float mindp = float.MaxValue; for (int i = 0; i < 3; i++) { if (i != curax) { float dp = Math.Abs(Vector3.Dot(cdir, axes[i])); if (dp < mindp) { mindp = dp; minax = i; } } } DraggedAxisSideDir = axes[minax]; break; } if (DraggedAxis == WidgetAxis.XYZ) { //all axes, move in the screen plane float ad1 = Math.Abs(Vector3.Dot(cdir, Vector3.UnitY)); float ad2 = Math.Abs(Vector3.Dot(cdir, Vector3.UnitZ)); DraggedAxisDir = Vector3.Normalize(Vector3.Cross(cdir, (ad1 > ad2) ? Vector3.UnitY : Vector3.UnitZ)); DraggedAxisSideDir = Vector3.Normalize(Vector3.Cross(cdir, DraggedAxisDir)); } bool hit = GetAxisRayHit(DraggedAxisDir, DraggedAxisSideDir, camrel, ray, out DragStartVec); if ((MousedAxis == WidgetAxis.None) || !hit) { IsDragging = false; } } else if (IsDragging) { //continue drag. Vector3 newvec; bool hit = GetAxisRayHit(DraggedAxisDir, DraggedAxisSideDir, camrel, ray, out newvec); if (hit) { Vector3 diff = newvec - DragStartVec; switch (DraggedAxis) { case WidgetAxis.X: diff.Y = 0; diff.Z = 0; break; case WidgetAxis.Y: diff.X = 0; diff.Z = 0; break; case WidgetAxis.Z: diff.X = 0; diff.Y = 0; break; } if (ObjectSpace) { diff = ori.Multiply(diff); } if (diff.Length() < 10000.0f) //limit movement in one go, to avoid losing the widget... { Vector3 oldpos = Position; Position = DragStartPosition + diff; if (Position != oldpos) { OnPositionChange?.Invoke(Position, oldpos); } } } } WasDragging = IsDragging; }
public void MoveCursor(int index) { CursorPosition += index; OnPositionChange?.Invoke(this); }
private void Start() { positionAttribute.OnChanged += (x) => OnPositionChange?.Invoke(x); rotationAttribute.OnChanged += (x) => OnRotationChange?.Invoke(x); scaleAttribute.OnChanged += (x) => OnScaleChange?.Invoke(x); }
public void Run() { //int position = (int)player.CurrentPosition; OnPositionChange?.Invoke((int)player.CurrentPosition, (int)player.Duration, player.CurrentWindowIndex); handler.PostDelayed(this, DELAY_MS); }