/// <summary> /// Wait for all the specified activity to finish before returning from /// this method. This will freeze out user input, and so it is generally /// recommended that you use <c>PActivity.StartTime</c> and /// <c>PActivity.StartAfter</c> to offset activities instead of using /// this method. /// </summary> public virtual void WaitForActivity(PActivity activity) { while (activityScheduler.ActivitiesReference.Contains(activity)) { ProcessActivitiesNow(); } }
/// <summary> /// Animate the camera's view matrix from its current value when the activity /// starts to the new destination matrix value. /// </summary> /// <param name="aCamera">The camera whose view matrix will be animated.</param> /// <param name="aMatrix">The final matrix value.</param> /// <param name="duration"> /// The amount of time that the animation should take. /// </param> /// <returns> /// The newly scheduled activity, if the duration is greater than 0; else null. /// </returns> protected virtual PActivity AnimateCameraViewMatrixTo(PCamera aCamera, PMatrix aMatrix, int duration) { bool wasOldAnimation = false; // first stop any old animations. if (navigationActivity != null) { navigationActivity.Terminate(); wasOldAnimation = true; } if (duration == 0) { aCamera.ViewMatrix = aMatrix; return(null); } PMatrix source = aCamera.ViewMatrixReference; if (!source.MatrixReference.Equals(aMatrix.MatrixReference)) { navigationActivity = aCamera.AnimateViewToMatrix(aMatrix, duration); ((PTransformActivity)navigationActivity).SlowInSlowOut = !wasOldAnimation; return(navigationActivity); } return(null); }
/// <summary> /// Sets the view position of the scrollDirector. /// </summary> /// <param name="point">The new position.</param> /// <param name="animate">Indicates whether or not to animate the transition.</param> protected virtual void SetViewPosition(Point point, bool animate) { if (view == null) { return; } float oldX = 0, oldY = 0, x = point.X, y = point.Y; PointF vp = this.ViewPosition; oldX = vp.X; oldY = vp.Y; // Send the scroll director the exact view position and let it // interpret it as needed float newX = x; float newY = y; if ((oldX != newX) || (oldY != newY)) { if (animate) { scroll = new ScrollActivity(ViewPosition, point, scrollDirector, animateScrollDuration); Canvas.Root.AddActivity(scroll); } else { scrollDirector.SetViewPosition(newX, newY); } } }
/// <summary> /// Create and show a new error /// </summary> /// <param Name="error">The text to display to the user</param> /// <param Name="camera">The camera to display the error on</param> /// <param Name="duration">How long to display the error for</param> public Error(string error, PCamera camera, int duration = 3000) { //Slightly shade the background to bring attention to the error PPath background = PPath.CreateRectangle(0, 0, camera.ViewBounds.Width, camera.ViewBounds.Height); background.Brush = new SolidBrush(Color.FromArgb(30, 220, 220, 220)); AddChild(background); //Add the error text to the center of the screen PText errorText = new PText(error); errorText.ConstrainWidthToTextWidth = false; errorText.Font = new Font("Century Gothic", 18); errorText.TextAlignment = StringAlignment.Center; float height = errorText.Font.Height; float width = camera.Canvas.FindForm().Width; float y = (camera.Canvas.FindForm().Height - height) / 2; errorText.Bounds = new RectangleF(0, y, width, height); AddChild(errorText); //Display the error camera.AddChild(this); //Remove the error after the required time PActivity dissapear = new PActivity(duration); dissapear.ActivityFinished += activityFinished; camera.Canvas.Root.AddActivity(dissapear); }
public IActionResult CreateActivity(PActivity FromForm) { if (HttpContext.Session.GetInt32("Uuid") == null) { System.Console.WriteLine("no user in session"); return(Redirect("/")); } if (ModelState.IsValid) { if (FromForm.DateNTime <= DateTime.Now) { System.Console.WriteLine("cant select past date"); ModelState.AddModelError("DateNTime", "You must enter a future date."); return(View("NewActivity")); } FromForm.CreatorId = (int)HttpContext.Session.GetInt32("Uuid"); _context.Add(FromForm); _context.SaveChanges(); return(RedirectToAction("Home")); } else { if (FromForm.DateNTime == null || FromForm.DateNTime < DateTime.Now) { ModelState.AddModelError("DateNTime", "Select a valid date please..."); System.Console.WriteLine("acitivity did not post invalid model"); return(View("NewActivity")); } return(NewActivity()); } }
/// <summary> /// Schedules the drag activity to run. /// </summary> /// <param name="e">A PInputEventArgs that contains the event data.</param> protected virtual void StartDragActivity(PInputEventArgs e) { dragActivity = new PActivity(-1, PUtil.DEFAULT_ACTIVITY_STEP_RATE); dragActivity.ActivityDelegate = this; e.Camera.Root.AddActivity(dragActivity); }
/// <summary> /// When the focus animation finishes, show the hires version of the slide /// </summary> protected void FocusActivityFinished(PActivity activity) { PTransformActivity transformActivity = activity as PTransformActivity; PNode.PNodeTransformTarget nodeTarget = (PNode.PNodeTransformTarget)transformActivity.ActivityTarget; PNode slide = nodeTarget.Target; ((PMultiSizeImage)slide).ShowThumb = false; }
/// <summary> /// When the hilite animation finishes, put the slide back in its proper place /// </summary> protected void HiliteActivityFinished(PActivity activity) { PTransformActivity transformActivity = activity as PTransformActivity; PNode.PNodeTransformTarget nodeTarget = (PNode.PNodeTransformTarget)transformActivity.ActivityTarget; PNode slide = nodeTarget.Target; slideBar.AddChild((int)slide.Tag, slide); // Reinsert slide in the right slot }
public override PActivity DirectCameraViewToFocus(PCamera aCamera, PNode aFocusNode, int duration) { PActivity animateViewToMatrix = base.DirectCameraViewToFocus(aCamera, aFocusNode, duration); PControl controlNode = (PControl)aFocusNode; aCamera.Root.WaitForActivities(); controlNode.CurrentCamera = aCamera; controlNode.Editing = true; return(animateViewToMatrix); }
protected void ActivityStepped(PActivity activity) { if (fRed) { aNode.Brush = new SolidBrush(Color.Red); } else { aNode.Brush = new SolidBrush(Color.Green); } fRed = !fRed; }
public IActionResult DeleteActivity(int PActivityId) { if (HttpContext.Session.GetInt32("Uuid") == null) { return(Redirect("/")); } System.Console.WriteLine("clicked activitydelete"); PActivity ActivityToDelete = _context.Activities.FirstOrDefault(a => a.PActivityId == PActivityId); _context.Remove(ActivityToDelete); _context.SaveChanges(); return(RedirectToAction("Home")); }
protected void ActivityStepped(PActivity activity) { if (fRed) { aNode.Brush = Color.Red; } else { aNode.Brush = Color.Green; } fRed = !fRed; }
public override void Initialize() { PLayer layer = Canvas.Layer; PNode a = PPath.CreateRectangle(0, 0, 100, 80); PNode b = PPath.CreateRectangle(0, 0, 100, 80); layer.AddChild(a); layer.AddChild(b); PActivity a1 = a.AnimateToPositionScaleRotation(200, 200, 1, 0, 5000); PActivity a2 = b.AnimateToPositionScaleRotation(200, 200, 1, 0, 5000); a2.StartAfter(a1); }
/// <summary> /// Animates the camera's view to keep the control node on the screen and at 100 /// percent scale with minimal view movement. /// </summary> /// <param name="aCamera">The camera whose view will be animated.</param> /// <param name="aControlNode">The control node to animate to.</param> /// <param name="path">The pick path through which the control node was picked.</param> /// <param name="duration">The length of the animation.</param> /// <returns> /// The activity that animates the camera's view to the control node. /// </returns> public virtual PActivity DirectCameraViewToControl(PCamera aCamera, PControl aControlNode, PPickPath path, int duration) { Matrix originalViewMatrix = aCamera.ViewMatrix; // Scale the canvas to include SizeFx s = new SizeFx(1, 0); s = aControlNode.GlobalToLocal(s); float scaleFactor = s.Width / aCamera.ViewScale; PointFx scalePoint = PUtil.CenterOfRectangle(aControlNode.GlobalFullBounds); if (scaleFactor != 1) { aCamera.ScaleViewBy(scaleFactor, scalePoint.X, scalePoint.Y); } // Pan the canvas to include the view bounds with minimal canvas // movement. aCamera.AnimateViewToPanToBounds(aControlNode.GlobalFullBounds, 0); // Get rid of any white space. The canvas may be panned and // zoomed in to do this. But make sure not stay constrained by max // magnification. //FillViewWhiteSpace(aCamera); Matrix resultingMatrix = aCamera.ViewMatrix; aCamera.ViewMatrix = originalViewMatrix; PControl controlNode = (PControl)aControlNode; // Animate the canvas so that it ends up with the given // view transform. PActivity animateCameraViewActivity = AnimateCameraViewMatrixTo(aCamera, resultingMatrix, duration); aCamera.Root.WaitForActivities(); Matrix pathTransform = path.GetPathTransformTo(controlNode); PointFx point = new PointFx(controlNode.X, controlNode.Y); PointFx pf = MatrixExtensions.Transform(pathTransform, point); controlNode.ControlLocation = new System.Drawing.Point((int)pf.X, (int)pf.Y); controlNode.CurrentCanvas = path.TopCamera.Canvas; controlNode.Editing = true; return(animateCameraViewActivity); }
public override void Initialize() { long currentTime = PUtil.CurrentTimeMillis; // Create a new node that we will apply different activities to, and // place that node at location 200, 200. aNode = new PNode(); //PPath.CreateRectangle(0, 0, 100, 80); aNode.SetBounds(0, 0, 100, 80); aNode.Brush = new SolidBrush(Color.Blue); PLayer layer = Canvas.Layer; layer.AddChild(aNode); aNode.SetOffset(200, 200); // Create a new custom "flash" activity. This activity will start running in // five seconds, and while it runs it will flash aNode's brush color between // red and green every half second. The same effect could be achieved by // extending PActivity and override OnActivityStep. PActivity flash = new PActivity(-1, 500, currentTime + 5000); flash.ActivityStepped = new ActivitySteppedDelegate(ActivityStepped); Canvas.Root.AddActivity(flash); // Use the PNode animate methods to create three activities that animate // the node's position. Since our node already descends from the root node the // animate methods will automatically schedule these activities for us. PActivity a1 = aNode.AnimateToPositionScale(0f, 0f, 0.5f, 5000); PActivity a2 = aNode.AnimateToPositionScale(100f, 0f, 1.5f, 5000); //PActivity a3 = aNode.AnimateToPositionScale(200f, 100f, 1f, 5000); PActivity a3 = aNode.AnimateToPositionScale(20f, 200f, 1f, 5000); // the animate activities will start immediately (in the next call to PRoot.processInputs) // by default. Here we set their start times (in PRoot global time) so that they start // when the previous one has finished. a1.StartTime = currentTime; a2.StartAfter(a1); a3.StartAfter(a2); // or the previous three lines could be replaced with these lines for the same effect. //a2.setStartTime(currentTime + 5000); //a3.setStartTime(currentTime + 10000); base.Initialize(); }
protected void ActivityStepped(PActivity activity) { PRoot root = Canvas.Root; if (root.PaintInvalid || root.ChildPaintInvalid) { PNodeList cameraChildren = Canvas.Camera.ChildrenReference; foreach (PNode each in cameraChildren) { if (each is PHandle) { PHandle handle = (PHandle)each; handle.RelocateHandle(); } } } }
public IActionResult ActivityInfo(int PActivityId) { if (HttpContext.Session.GetInt32("Uuid") == null) { return(Redirect("/")); } int Uuid = (int)HttpContext.Session.GetInt32("Uuid"); User You = _context.Users.FirstOrDefault(u => u.UserId == Uuid); ViewBag.ThisUser = You; PActivity ThisActivity = _context.Activities .Include(a => a.Creator) .Include(a => a.UsersWhoJoined) .ThenInclude(u => u.UserJoined) .FirstOrDefault(a => a.PActivityId == PActivityId); return(View("ActivityInfo", ThisActivity)); }
public override void Initialize() { PCanvas c = Canvas; PActivity updateHandles = new PActivity(-1, 0); updateHandles.ActivityStepped = new ActivitySteppedDelegate(ActivityStepped); PPath rect = PPath.CreateRectangle(0, 0, 100, 100); rect.Brush = Color.Red; c.Layer.AddChild(rect); c.Camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthEastLocator(rect))); c.Camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthWestLocator(rect))); c.Camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthEastLocator(rect))); c.Camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthWestLocator(rect))); c.Root.ActivityScheduler.AddActivity(updateHandles, true); }
public override void Initialize() { Canvas.RegionManagement = true; PLayer layer = Canvas.Layer; PRoot root = Canvas.Root; Random r = new Random(); for (int i = 0; i < 400; i++) { PNode n = PPath.CreateRectangle(0, 0, 100, 80); n.TranslateBy(10000 * (float)r.NextDouble(), 10000 * (float)r.NextDouble()); n.Brush = Color.FromNonPremultiplied((int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), 255); layer.AddChild(n); } Canvas.Camera.AnimateViewToCenterBounds(layer.GlobalFullBounds, true, 0); PActivity a = new PActivity(-1, 20); a.ActivityStepped = new ActivitySteppedDelegate(ActivityStepped); root.AddActivity(a); }
/// <summary> /// Called when the drag activity stops running. /// </summary> /// <param name="activity">The drag activity.</param> public void ActivityFinished(PActivity activity) { OnDragActivityFinalStep(source, dragEvent); }
/// <summary> /// Removes the first occurrence of a specific activity from the list. /// </summary> /// <param name="activity">The activity to remove from the list.</param> public void Remove(PActivity activity) { List.Remove(activity); }
/// <summary> /// Called when the drag activity starts running. /// </summary> /// <param name="activity">The drag activity.</param> public void ActivityStarted(PActivity activity) { OnDragActivityFirstStep(source, dragEvent); }
/// <summary> /// Called when the drag activity is running. /// </summary> /// <param name="activity">The drag activity.</param> public void ActivityStepped(PActivity activity) { OnDragActivityStep(source, dragEvent); }
/// <summary> /// Determines whether the list contains a specific activity. /// </summary> /// <param name="activity">The activity to locate in the list.</param> /// <returns> /// True if the activity is found in the list; otherwise, false. /// </returns> public bool Contains(PActivity activity) { return(List.Contains(activity)); }
/// <summary> /// Stops the drag activity. /// </summary> /// <param name="e">A PInputEventArgs that contains the event data.</param> private void StopDragActivity(PInputEventArgs e) { dragActivity.Terminate(); dragActivity = null; }
/// <summary> /// Determines the index of a specific activity in the list. /// </summary> /// <param name="activity">The activity to locate in the list.</param> /// <returns> /// The index of the activity if found in the list; otherwise, -1. /// </returns> public int IndexOf(PActivity activity) { return(List.IndexOf(activity)); }
/// <summary> /// Adds a activity to the list. /// </summary> /// <param name="activity">The activity to add.</param> /// <returns>The position into which the new activity was inserted.</returns> public int Add(PActivity activity) { return(List.Add(activity)); }
//**************************************************************** // Activities - Methods for scheduling activities to run. //**************************************************************** /// <summary> /// Overridden. Add an activity to the activity scheduler associated with /// this root. /// </summary> /// <param name="activity">The new activity to scheduled.</param> /// <returns> /// True if the activity is successfully scheduled; otherwise, false. /// </returns> /// <remarks> /// Activities are given a chance to run during each call to the root's /// <c>ProcessInputs</c> method. When the activity has finished running it /// will automatically get removed. /// </remarks> public override bool AddActivity(PActivity activity) { ActivityScheduler.AddActivity(activity); return(true); }
public void ActivityStepped(PActivity activity) { RotateNodes(); }
/// <summary> /// Inserts a activity to the list at the specified position. /// </summary> /// <param name="index"> /// The zero-based index at which the activity should be inserted. /// </param> /// <param name="activity">The activity to insert into the list.</param> public void Insert(int index, PActivity activity) { List.Insert(index, activity); }