Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues in sample apps #514

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Accessibility/Highlighter/ClientForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) Microsoft. All rights reserved.
// // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Drawing;
Expand Down Expand Up @@ -49,7 +49,6 @@ public ClientForm()
_eventTimer.Elapsed += OnTimerTick;
_eventTimer.Enabled = false;
_eventTimer.AutoReset = false;
_timerInterval = tbInterval.Value;
_eventTimer.Interval = _timerInterval;

// Create highlight rectangle.
Expand Down Expand Up @@ -127,7 +126,7 @@ private void UpdateHighlight()
/// <summary>
/// Updates the highlight rectangle.
/// </summary>
/// <param name="sender">Ojbect that raised the event.</param>
/// <param name="sender">Object that raised the event.</param>
/// <param name="e">Event arguments.</param>
/// <remarks>The timer stops because AutoReset is false.</remarks>
private void OnTimerTick(object sender, EventArgs e)
Expand Down
58 changes: 29 additions & 29 deletions Animation/Per-FrameAnimation/ParticleEffects/FireworkEffect.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) Microsoft. All rights reserved.
// // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -48,12 +48,12 @@ protected void OnFrameCallback(object sender, EventArgs e)
UpdateParticles(_timeTracker.Update());
}

protected virtual void UpdateParticles(double deltatime)
protected virtual void UpdateParticles(double deltaTime)
{
//drop particles from mouse position
if (MouseDropsParticles && IsMouseOver)
{
_secondsUntilDrop -= deltatime;
_secondsUntilDrop -= deltaTime;
if (_secondsUntilDrop < 0.0)
{
AddRandomBurst(_lastMousePosition - new Vector(Radius/2.0, Radius/2.0), 1);
Expand All @@ -78,7 +78,7 @@ protected virtual void UpdateParticles(double deltatime)
{
p.Velocity += _gravity;
}
p.Location += p.Velocity*deltatime;
p.Location += p.Velocity*deltaTime;

if (BounceOffContainer)
{
Expand Down Expand Up @@ -118,12 +118,12 @@ protected override void OnOverlayRender(DrawingContext drawingContext)
foreach (var p in _particles)
{
//figure out where in the particles life we are
var particlelife = (_timeTracker.ElapsedTime - p.LifeTime).TotalSeconds/
var particleLife = (_timeTracker.ElapsedTime - p.LifeTime).TotalSeconds/
(p.DeathTime - p.LifeTime).TotalSeconds;
var currentcolor = Color.Multiply(p.StartColor, (float) (1.0 - particlelife)) +
Color.Multiply(p.EndColor, (float) particlelife);
Brush brush = new RadialGradientBrush(currentcolor,
Color.FromArgb(0, currentcolor.R, currentcolor.G, currentcolor.B));
var currentColor = Color.Multiply(p.StartColor, (float) (1.0 - particleLife)) +
Color.Multiply(p.EndColor, (float) particleLife);
Brush brush = new RadialGradientBrush(currentColor,
Color.FromArgb(0, currentColor.R, currentColor.G, currentColor.B));

var rect =
new RectangleGeometry(
Expand Down Expand Up @@ -193,7 +193,7 @@ public void AddRandomBurst(Point location, int count)

public static readonly DependencyProperty RadiusProperty =
DependencyProperty.Register(
"RadiusBase",
"Radius",
typeof (double),
typeof (FireworkEffect),
new FrameworkPropertyMetadata(15.0)
Expand Down Expand Up @@ -269,38 +269,38 @@ public void AddRandomBurst(Point location, int count)

public double Radius
{
get { return (double) GetValue(RadiusProperty); }
set { SetValue(RadiusProperty, value); }
get => (double)GetValue(RadiusProperty);
set => SetValue(RadiusProperty, value);
}

public double RadiusVariation
{
get { return (double) GetValue(RadiusVariationProperty); }
set { SetValue(RadiusVariationProperty, value); }
get => (double)GetValue(RadiusVariationProperty);
set => SetValue(RadiusVariationProperty, value);
}

public Color StartColor
{
get { return (Color) GetValue(StartColorProperty); }
set { SetValue(StartColorProperty, value); }
get => (Color)GetValue(StartColorProperty);
set => SetValue(StartColorProperty, value);
}

public Color EndColor
{
get { return (Color) GetValue(EndColorProperty); }
set { SetValue(EndColorProperty, value); }
get => (Color)GetValue(EndColorProperty);
set => SetValue(EndColorProperty, value);
}

public Color StartColorVariation
{
get { return (Color) GetValue(StartColorVariationProperty); }
set { SetValue(StartColorVariationProperty, value); }
get => (Color)GetValue(StartColorVariationProperty);
set => SetValue(StartColorVariationProperty, value);
}

public Color EndColorVariation
{
get { return (Color) GetValue(EndColorVariationProperty); }
set { SetValue(EndColorVariationProperty, value); }
get => (Color)GetValue(EndColorVariationProperty);
set => SetValue(EndColorVariationProperty, value);
}


Expand All @@ -314,20 +314,20 @@ public Color EndColorVariation

public double MouseDropDelay
{
get { return (double) GetValue(MouseDropDelayProperty); }
set { SetValue(MouseDropDelayProperty, value); }
get => (double)GetValue(MouseDropDelayProperty);
set => SetValue(MouseDropDelayProperty, value);
}

public double MouseDropDelayVariation
{
get { return (double) GetValue(MouseDropDelayVariationProperty); }
set { SetValue(MouseDropDelayVariationProperty, value); }
get => (double)GetValue(MouseDropDelayVariationProperty);
set => SetValue(MouseDropDelayVariationProperty, value);
}

public int ClickBurstSize
{
get { return (int) GetValue(ClickBurstSizeProperty); }
set { SetValue(ClickBurstSizeProperty, value); }
get => (int)GetValue(ClickBurstSizeProperty);
set => SetValue(ClickBurstSizeProperty, value);
}

#endregion
Expand Down
52 changes: 28 additions & 24 deletions Animation/Per-FrameAnimation/ParticleEffects/MagnitismCanvas.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// // Copyright (c) Microsoft. All rights reserved.
// // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -46,44 +46,48 @@ private void UpdateChildren(object sender, EventArgs e)
forces.Y -= BorderForce/Math.Max(1, RenderSize.Height - childRect.Bottom);

//each other child pushes away based on the square distance
foreach (UIElement otherchild in LogicalTreeHelper.GetChildren(this))
foreach (UIElement otherChild in LogicalTreeHelper.GetChildren(this))
{
//dont push against itself
if (otherchild == child)
//don't push against itself
if (otherChild == child)
continue;

var otherchildtruePosition = GetTruePosition(otherchild);
var otherchildRect = new Rect(otherchildtruePosition, otherchild.RenderSize);
var otherChildTruePosition = GetTruePosition(otherChild);
var otherChildRect = new Rect(otherChildTruePosition, otherChild.RenderSize);

//make sure rects aren't the same
if (otherchildRect == childRect)
if (otherChildRect == childRect)
continue;

double epsilon = 0.00001; // Define a small tolerance value

//ignore children with a size of 0,0
if (otherchildRect.Width == 0 && otherchildRect.Height == 0 ||
childRect.Width == 0 && childRect.Height == 0)
if (Math.Abs(otherChildRect.Width - 0) < epsilon &&
Math.Abs(otherChildRect.Height - 0) < epsilon ||
Math.Abs(childRect.Width - 0) < epsilon &&
Math.Abs(childRect.Height - 0) < epsilon)
continue;

//vector from current other child to current child
//are they overlapping? if so, distance is 0
var toChild = AreRectsOverlapping(childRect, otherchildRect)
var toChild = AreRectsOverlapping(childRect, otherChildRect)
? new Vector(0, 0)
: VectorBetweenRects(childRect, otherchildRect);
: VectorBetweenRects(childRect, otherChildRect);

var length = toChild.Length;
if (length < 1)
{
length = 1;
var childCenter = GetCenter(childRect);
var otherchildCenter = GetCenter(otherchildRect);
var otherChildCenter = GetCenter(otherChildRect);
//compute toChild from the center of both rects
toChild = childCenter - otherchildCenter;
toChild = childCenter - otherChildCenter;
}

var childpush = ChildForce/length;
var childPush = ChildForce/length;

toChild.Normalize();
forces += toChild*childpush;
forces += toChild*childPush;
}

//add forces to velocity and store it for next iteration
Expand All @@ -108,14 +112,14 @@ private bool AreRectsOverlapping(Rect r1, Rect r2)

private Point IntersectInsideRect(Rect r, Point raystart, Vector raydir)
{
var xtop = raystart.X + raydir.X*(r.Top - raystart.Y)/raydir.Y;
var xbottom = raystart.X + raydir.X*(r.Bottom - raystart.Y)/raydir.Y;
var yleft = raystart.Y + raydir.Y*(r.Left - raystart.X)/raydir.X;
var yright = raystart.Y + raydir.Y*(r.Right - raystart.X)/raydir.X;
var top = new Point(xtop, r.Top);
var bottom = new Point(xbottom, r.Bottom);
var left = new Point(r.Left, yleft);
var right = new Point(r.Right, yright);
var xTop = raystart.X + raydir.X*(r.Top - raystart.Y)/raydir.Y;
var xBottom = raystart.X + raydir.X*(r.Bottom - raystart.Y)/raydir.Y;
var yLeft = raystart.Y + raydir.Y*(r.Left - raystart.X)/raydir.X;
var yRight = raystart.Y + raydir.Y*(r.Right - raystart.X)/raydir.X;
var top = new Point(xTop, r.Top);
var bottom = new Point(xBottom, r.Bottom);
var left = new Point(r.Left, yLeft);
var right = new Point(r.Right, yRight);
var tv = raystart - top;
var bv = raystart - bottom;
var lv = raystart - left;
Expand Down
11 changes: 5 additions & 6 deletions Clipboard/ClipboardViewer/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,11 @@ private void DumpAllClipboardContentsInternal()
if (dataObject == null)
{
clipboardInfo.Text =
clipboardInfo.Text =
"Can't access clipboard now! \n\nPlease click Dump All Clipboard Contents button again.";
}
else
{
// Update the availabe data formats
// Update the available data formats
UpdateAvailableDataFormats(dataObject);

// Update the all available data contents
Expand Down Expand Up @@ -345,7 +344,7 @@ private void CopyDataFromFile(IDataObject dataObject)
}

// Finally, consider a custom, application defined format.
// We use an arbitrary encoding here, for demonstartion purposes.
// We use an arbitrary encoding here, for demonstration purposes.
if ((bool) cbCustomSampleDataFormat.IsChecked)
{
fileName = null;
Expand Down Expand Up @@ -595,7 +594,7 @@ private string GetTextStringFromFile(string fileName, Encoding fileEncoding)
}
catch (IOException)
{
MessageBox.Show("File is not acessible.\n", "File Open Error");
MessageBox.Show("File is not accessible.\n", "File Open Error");
return null;
}

Expand Down Expand Up @@ -649,7 +648,7 @@ private void PasteTextDataToFile(string dataFormat, string textData, string file
}
catch (IOException)
{
MessageBox.Show("File is not acessible.\n", "File Write Error");
MessageBox.Show("File is not accessible.\n", "File Write Error");
return;
}

Expand Down Expand Up @@ -677,7 +676,7 @@ private void PasteStreamDataToFile(Stream stream, string fileName)
}
catch (IOException)
{
MessageBox.Show("File is not acessible.\n", "File Write Error");
MessageBox.Show("File is not accessible.\n", "File Write Error");
}

fileWriteStream.SetLength(0);
Expand Down
Loading
Loading