// Update is called once per frame void Update() { timer += Time.deltaTime; if (spriteState == ResizeState.scaleDown) { float scale = Mathf.SmoothStep(maxSize, minSize, timer / duration); newScale = new Vector3(originalScale.x * scale, originalScale.y * scale, .0f); transform.localScale = newScale; if (timer > duration) { spriteState = ResizeState.scaleUp; timer = .0f; } } else { float scale = Mathf.SmoothStep(minSize, maxSize, timer / duration); newScale = new Vector3(originalScale.x * scale, originalScale.y * scale, .0f); transform.localScale = newScale; if (timer > duration) { spriteState = ResizeState.scaleDown; timer = .0f; } } }
/// <summary> /// Creates a layout data suiting the <paramref name="resizeState"/>. /// </summary> /// <param name="resizeState">The current state of the gesture</param> /// <returns>A layout data suiting the <paramref name="resizeState"/>.</returns> private LayoutData CreateLayoutData(ResizeState resizeState) { var layoutData = new CompositeLayoutData(resetToOriginalGraphStageData); if (resizeState == ResizeState.Shrinking) { layoutData.Items.Add(new FillAreaLayoutData { FixedNodes = { Items = nodes } }); if (state == GestureState.Finishing) { // only route edges for the final layout layoutData.Items.Add(new EdgeRouterData { AffectedNodes = { Items = nodes } }); } } else { if (resizeState == ResizeState.Both) { layoutData.Items.Add(new FillAreaLayoutData { FixedNodes = { Items = nodes } }); } layoutData.Items.Add(new ClearAreaLayoutData { AreaNodes = { Items = nodes } }); } return(layoutData); }
protected override void PostInit() { base.PostInit(); base.onCurrentSkillIDChanged = (Action <string, string>)Delegate.Combine(base.onCurrentSkillIDChanged, new Action <string, string>(this.ScaleColliderBySkillID)); this._state = ResizeState.Idle; this._origCenter = this.boxCollider.center; this._origSize = this.boxCollider.size; this._curEntry = null; }
/// <summary> /// A <see cref="LayoutExecutor"/> that is used while dragging the node. /// </summary> private LayoutExecutor GetDragLayoutExecutor() { var oldResizeState = resizeState; resizeState = GetResizeState(); return((resizeState == oldResizeState && executor != null) ? executor : new DragLayoutExecutor(graphControl, CreateLayout(resizeState), nodes) { LayoutData = CreateLayoutData(resizeState), RunInThread = true, Duration = TimeSpan.FromMilliseconds(150) }); }
private static void DataGrid_MouseLeave(object sender, MouseEventArgs e) { var grid = sender as SfDataGrid; if (_currentState == ResizeState.StartResize) { string savedParams = string.Empty; SaveParameters(grid, out savedParams); if (!string.IsNullOrEmpty(savedParams)) { LoadParameters(grid, savedParams); } _currentState = ResizeState.NoResize; } }
protected override void LateUpdate() { base.LateUpdate(); if (this._state == ResizeState.InStateWaiting) { if (this.GetCurrentNormalizedTime() > this._curEntry.normalizedTimeStart) { this.boxCollider.size = this._curEntry.size; this.boxCollider.center = this._curEntry.center; this._state = ResizeState.InStateResized; } } else if ((this._state == ResizeState.InStateResized) && (this.GetCurrentNormalizedTime() > this._curEntry.normalizedTimeStop)) { this.boxCollider.size = this._origSize; this.boxCollider.center = this._origCenter; this._state = ResizeState.Idle; } }
private void ScaleColliderBySkillID(string from, string to) { ResizeColliderEntry entry = this.ScaleBySkillIDsContains(to); if (entry != null) { this._curEntry = entry; this._state = ResizeState.InStateWaiting; } else if (this._state == ResizeState.InStateResized) { this.boxCollider.size = this._origSize; this.boxCollider.center = this._origCenter; this._curEntry = null; this._state = ResizeState.Idle; } else if (this._state == ResizeState.InStateWaiting) { this._curEntry = null; this._state = ResizeState.Idle; } }
// Use this for initialization void Start() { originalScale = transform.localScale; // random start if (randomStart) { timer = Random.value * duration; float scale = Mathf.SmoothStep(maxSize, minSize, timer / duration); newScale = new Vector3(originalScale.x * scale, originalScale.y * scale, .0f); transform.localScale = newScale; if (Random.value > 0.5) { spriteState = ResizeState.scaleDown; } else { spriteState = ResizeState.scaleUp; } } }
/// <summary> /// Creates a layout algorithm suiting the <paramref name="resizeState"/>. /// </summary> /// <param name="resizeState">The current state of the gesture</param> /// <returns>A layout algorithm suiting the <paramref name="resizeState"/>.</returns> private ILayoutAlgorithm CreateLayout(ResizeState resizeState) { var sequentialLayout = new SequentialLayout(); if (resizeState == ResizeState.Shrinking) { // fill the free space of the shrunken node fillLayout = new FillAreaLayout { ComponentAssignmentStrategy = ComponentAssignmentStrategy.Single }; sequentialLayout.AppendLayout(fillLayout); if (this.state == GestureState.Finishing) { // only route edges for the final layout sequentialLayout.AppendLayout(new EdgeRouter { Scope = Scope.RouteEdgesAtAffectedNodes }); } } else { if (resizeState == ResizeState.Both) { // fill the free space of the resized node fillLayout = new FillAreaLayout { ComponentAssignmentStrategy = ComponentAssignmentStrategy.Single }; sequentialLayout.AppendLayout(fillLayout); } // clear the space of the moved/enlarged node sequentialLayout.AppendLayout(new ClearAreaLayout { ComponentAssignmentStrategy = ComponentAssignmentStrategy.Single, ClearAreaStrategy = ClearAreaStrategy.Local, ConsiderEdges = true }); } return(new GivenCoordinatesStage(sequentialLayout)); }
private void Editor_MouseDown(object sender, MouseEventArgs e) { mouseLoc = e.Location; // check resize actions if (selected != default) { bool CheckBoundEntrance(int x, int y) => x - resizeBoundSize <e.X && y - resizeBoundSize <e.Y && x + resizeBoundSize> e.X && y + resizeBoundSize> e.Y; if (CheckBoundEntrance(selected.X, selected.Y)) { resizeState = ResizeState.TopLeft; } if (CheckBoundEntrance(selected.X + selected.Width, selected.Y)) { resizeState = ResizeState.TopRight; } if (CheckBoundEntrance(selected.X, selected.Y + selected.Height)) { resizeState = ResizeState.BottomLeft; } if (CheckBoundEntrance(selected.X + selected.Width, selected.Y + selected.Height)) { resizeState = ResizeState.BottomRight; } resizeOrigin = e.Location; if (resizeState != ResizeState.Idle) { return; } } // check selection actions shapeToolbar.Visible = false; selected = default; foreach (var s in shapes.OrderByDescending(p => p.Order)) { if (s.X < e.X && s.Y < e.Y && s.X + s.Width > e.X && s.Y + s.Height > e.Y) { selected = s; AdjustToolbarsValues(); shapeToolbar.Visible = true; break; } } if (selected != default) { dragOrigin = e.Location; } renderBox.Refresh(); }
private void Editor_MouseUp(object sender, MouseEventArgs e) { dragOrigin = default; isInDrag = false; resizeState = ResizeState.Idle; }
private static void DataGrid_ResizingColumns(object sender, ResizingColumnsEventArgs e) { _currentState = ResizeState.StartResize; }