本文整理汇总了C#中System.Windows.Shapes.Rectangle.SizeTo方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.SizeTo方法的具体用法?C# Rectangle.SizeTo怎么用?C# Rectangle.SizeTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Shapes.Rectangle
的用法示例。
在下文中一共展示了Rectangle.SizeTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplicationCanvas
public ApplicationCanvas()
{
avg = new Rectangle();
avg.Fill = Brushes.Red;
avg.AttachTo(this);
avg.SizeTo(16, 16);
avg.Opacity = 0.2;
//Canvas.SetZIndex(avg, 1000);
f.Fill = Brushes.Yellow;
f.AttachTo(this);
f.SizeTo(16, 16);
f.Opacity = 0.5;
}
示例2: OrcasAvalonApplicationCanvas
//.........这里部分代码省略.........
))
{
InfoOverlayShadowOpacity.Opacity = 0.8;
InfoOverlayText.Text = "You won!\n\n:)";
ResetOverlay.AttachTo(TouchOverlay);
if (AtWin != null)
AtWin();
return;
}
t.TouchOverlay.Hide();
100.AtDelay(
delegate
{
AI();
t.TouchOverlay.Show();
if (Tiles.Any(
k =>
{
if (k.Value != -1)
return false;
return k.IsUnderAttack(-1, 4);
}
))
{
InfoOverlayShadowOpacity.Opacity = 0.8;
InfoOverlayText.Text = "You lost!\n\n:(";
ResetOverlay.AttachTo(TouchOverlay);
if (AtLoss != null)
AtLoss();
return;
}
}
);
};
};
var TileContainer = new Canvas().AttachTo(this);
#region build board
for (int x = 0; x < Intersections; x++)
for (int y = 0; y < Intersections; y++)
{
var t = new Tile(x, y);
t.Container.AttachTo(TileContainer);
t.TouchOverlay.AttachTo(TouchOverlay);
Tiles[x + y * Intersections] = t;
Tiles_WithEvents(t);
}
#endregion
#region add logo
var img = new com.abstractatech.gomoku.Avalon.Images.jsc
{
}.MoveTo(DefaultWidth - 96, DefaultHeight - 96).AttachTo(TileContainer);
#endregion
ResetOverlay.AttachTo(TouchOverlay);
InfoOverlay.AttachTo(this);
TouchOverlay.AttachTo(this);
this.SizeChanged +=
delegate
{
TileContainer.MoveTo(
(this.Width - DefaultWidth) /2,
(this.Height - DefaultHeight) /2
);
TouchOverlay.MoveTo(
(this.Width - DefaultWidth) / 2,
(this.Height - DefaultHeight) / 2
);
ResetOverlay.SizeTo(this.Width, this.Height);
InfoOverlay.SizeTo(this.Width, this.Height);
InfoOverlayShadow.SizeTo(this.Width, this.Height);
//TouchOverlay.SizeTo(this.Width, this.Height);
InfoOverlayText.MoveTo(0, (this.Height - 180) / 2);
InfoOverlayText.SizeTo(this.Width, 180);
};
}
示例3: ApplicationCanvas
public ApplicationCanvas()
{
r.Fill = Brushes.Red;
r.AttachTo(this);
r.MoveTo(0, 0);
this.SizeChanged += (s, e) => r.SizeTo(this.Width, this.Height);
space = new Rectangle
{
Fill = Brushes.White,
Opacity = 0.5
}.AttachTo(this);
space.SizeTo(64, 64 + 4 + 64);
this.SizeChanged += (s, e) => space.MoveTo(this.Width - 64 - 4 - 64 - 4, this.Height - 64 - 4 - 64 - 4);
up = new Rectangle
{
Fill = Brushes.White,
Opacity = 0.5
}.AttachTo(this);
up.SizeTo(64, 64);
this.SizeChanged += (s, e) => up.MoveTo(this.Width - 64 - 4, this.Height - 64 - 4 - 64 - 4);
down = new Rectangle
{
Fill = Brushes.White,
Opacity = 0.5
}.AttachTo(this);
down.SizeTo(64, 64);
this.SizeChanged += (s, e) => down.MoveTo(this.Width - 64 - 4, this.Height - 64 - 4);
control = new Rectangle
{
Fill = Brushes.White,
Opacity = 0.5
}.AttachTo(this);
control.SizeTo(64 + 4 + 64, 64);
this.SizeChanged += (s, e) => control.MoveTo(4, this.Height - 64 - 4 - 64 - 4);
left = new Rectangle
{
Fill = Brushes.White,
Opacity = 0.5
}.AttachTo(this);
left.SizeTo(64, 64);
this.SizeChanged += (s, e) => left.MoveTo(4, this.Height - 64 - 4);
right = new Rectangle
{
Fill = Brushes.White,
Opacity = 0.5
}.AttachTo(this);
right.SizeTo(64, 64);
this.SizeChanged += (s, e) => right.MoveTo(4 + 64 + 4, this.Height - 64 - 4);
}
示例4: ApplicationCanvas
public ApplicationCanvas()
{
{
var r = new Rectangle();
r.Fill = Brushes.Black;
r.AttachTo(this);
r.MoveTo(0, 0);
r.Opacity = 0.9;
this.SizeChanged += (s, e) => r.SizeTo(this.Width, this.Height / 2);
}
{
var r = new Rectangle();
r.Fill = Brushes.Black;
r.AttachTo(this);
this.SizeChanged += (s, e) => r.MoveTo(0, this.Height / 2).SizeTo(this.Width, this.Height / 2);
}
var VocabularyLines = Vocabulary.Trim().Split('\n');
var v = VocabularyLines.Select(
k =>
{
var verbs = k.Split(':');
return new { A = verbs[0].Trim(), B = verbs[1].Trim() };
}
).Randomize().AsCyclicEnumerator();
var az = 0.5;
var ax = 0.0;
var ABCanvas = new Canvas().AttachTo(this);
var A = new TextBox
{
BorderThickness = new Thickness(0),
Background = Brushes.Transparent,
TextAlignment = System.Windows.TextAlignment.Center,
Foreground = Brushes.White,
Text = "suur ettevõte",
IsReadOnly = true,
FontSize = 70
};
A.AttachTo(ABCanvas);
var B = new TextBox
{
BorderThickness = new Thickness(0),
Background = Brushes.Transparent,
TextAlignment = System.Windows.TextAlignment.Center,
Foreground = Brushes.White,
Text = "large-scale enterprise",
IsReadOnly = true,
FontSize = 70
};
var MoveNextDisabled = false;
Action MoveNext = delegate
{
if (MoveNextDisabled)
return;
MoveNextDisabled = true;
v.MoveNext();
A.Text = v.Current.A;
B.Text = v.Current.B;
600.AtDelay(() => MoveNextDisabled = false);
};
MoveNext();
B.AttachTo(ABCanvas);
B.MoveTo(0, 64);
Action Update =
delegate
{
if (Math.Abs(ax) > 0.4)
MoveNext();
az = Math.Min(1, az);
az = Math.Max(0, az);
var max = this.Height / 6;
var min = this.Height / 3;
// az = 1 is 0 degrees
// az = 0 is 90 degrees
az = 1 - az;
az -= 0.05;
az *= 10;
//.........这里部分代码省略.........
示例5: ApplicationCanvas
public ApplicationCanvas()
{
//return;
Background = Brushes.Black;
var OverlayWhite = new Rectangle
{
Fill = Brushes.White
}.AttachTo(this);
this.Overlay = new Rectangle
{
Fill = Brushes.Black
}.AttachTo(this);
var c = new Canvas().AttachTo(this);
this.SizeChanged +=
(s, e) =>
{
//Console.WriteLine(new { Width, Height, this.ActualWidth, this.ActualHeight });
OverlayWhite.SizeTo(
this.Width,
this.Height
);
Overlay.SizeTo(
this.Width,
this.Height
);
c.MoveTo(
this.Width * 0.5,
this.Height * 0.5
);
};
Func<double, double, Image> f =
(o, x) =>
{
return new white_jsc
{
Opacity = o
}.AttachTo(c).MoveTo(
white_jsc.ImageDefaultWidth / -2 + x,
white_jsc.ImageDefaultHeight / -2
);
};
var a = new List<Action<bool>>();
var ss = 640;
var ia = 1;
for (int i = -ss; i <= 0; i += ia)
{
ia += 2;
{
var o = (ss + i + 64) / (double)(ss + 64);
var l = f(o, -i);
var r = f(o, i);
Action<bool> j =
n =>
{
l.Show(n);
r.Show(n);
};
j(false);
a.Add(j);
}
}
{
var l = f(1, 0);
l.Hide();
Action<bool> j =
n =>
{
if (n)
{
Overlay.Fill = Brushes.White;
l.Show();
return;
}
15.AtDelay(
delegate
{
Overlay.Fill = Brushes.Black;
}
);
Action<int, int, int> ShakeAt = null;
//.........这里部分代码省略.........
示例6: ApplicationCanvas
public ApplicationCanvas()
{
Width = DefaultWidth;
Height = DefaultHeight;
this.Background = Brushes.Blue;
var left = new PartialView(Colors.Blue, true).AttachTo(this);
var right = new PartialView(Colors.Green).AttachTo(this).MoveTo(DefaultWidth / 2, 0);
this.InfoOverlay = new Canvas().AttachTo(this);
this.About = new TextBox
{
BorderThickness = new Thickness(0),
Background = Brushes.Transparent,
Foreground = Brushes.Black,
AcceptsReturn = true,
Text =
@"Windows Presentation Foundation Touch demo
- Debuggable under .NET (fullscreen when maximized and touch events)
- Adobe Flash 10.1 version via jsc
No touch events in fullscreen
Browser fullscreen feature shall be used instead
Tested for IE, Firefox, Chrome
- Javascript version for Firefox4 via jsc
- Tested with 4 touch points on Dell Latitude XT
- Galaxy S/ Galaxy Tab within browser have only 1 touchpoint
- 2012.09 flash no longer available on android
- multitouch seems to work in firefox/ flash (11.0)
- multitouch seems to work in ie/flash (10.0)
- p2p LAN no longer works?
- Works on AIR for Android! :) 2013-03-05
- Works on AIR for iPad! :) 2014-03-01
"
}.AttachTo(InfoOverlay).MoveTo(128, 32);
var c1 = new cloud_mid().AttachTo(InfoOverlay);
var c2 = new cloud_mid().AttachTo(InfoOverlay);
this.TouchOverlay = new Canvas
{
}.AttachTo(this); //.SizeTo(DefaultWidth, DefaultHeight);
var TouchArea = new Rectangle
{
Width = DefaultWidth,
Height = DefaultHeight,
Fill = Brushes.White,
Opacity = 0
}.AttachTo(TouchOverlay);
var t = TouchOverlay.ToTouchEvents(
m =>
{
// a new reusable finger introduced by the system!
var Content = new Canvas();
new Avalon.Images.white_jsc().AttachTo(Content).MoveTo(
Avalon.Images.white_jsc.ImageDefaultWidth / -2,
Avalon.Images.white_jsc.ImageDefaultHeight / -2
);
var CurrentTouchPoint = default(Tuple<double, double>);
Func<Tuple<double, double>> GetTouchPoint = () => CurrentTouchPoint;
m.TouchDown += e =>
{
var p = e.GetTouchPoint(TouchOverlay).Position;
CurrentTouchPoint = Tuple.Create(p.X, p.Y);
Content.AttachTo(InfoOverlay);
};
m.TouchUp += e =>
{
CurrentTouchPoint = null;
Content.Orphanize();
};
m.TouchMove += e =>
{
var p = e.GetTouchPoint(TouchOverlay).Position;
CurrentTouchPoint = Tuple.Create(p.X, p.Y);
//.........这里部分代码省略.........
示例7: ImageCarouselCanvas
public ImageCarouselCanvas(Arguments args)
{
this.CloseOnClick = true;
this.Container = new Canvas
{
Width = DefaultWidth,
Height = DefaultHeight
};
//var r = new Rectangle
//{
// Fill = Brushes.Red,
// Opacity = 0.05
//};
//r.SizeTo(DefaultWidth, DefaultHeight);
//r.AttachTo(this);
//this.Container.Background = Brushes.Transparent;
//this.Container.Background = Brushes.Red;
var y = 0;
var s = new Stopwatch();
s.Start();
var images = new List<XImage>();
#region AddImages
Func<Image, XImage> Add =
i =>
{
y += 32;
var n = new XImage
{
Image = i,
Opacity = 0,
Radius = 72
};
RenderOptions.SetBitmapScalingMode(i, BitmapScalingMode.Fant);
images.Add(n);
i.Opacity = 0;
i.AttachTo(this);
return n;
};
args.AddImages(Add);
#endregion
var size = 64;
Action<DispatcherTimer> AtAnimation = delegate { };
// .net is fast, but js will be slow :)
var randomphase = Math.PI * 2 * new Random().NextDouble();
#region AtIntervalWithTimer
var AnimationTimer = (1000 / 50).AtIntervalWithTimer(
t =>
{
var ms = s.ElapsedMilliseconds;
var i = 0;
AtAnimation(t);
// using for each must be the last thing in a method
// because .leave operator currently cannot be understood by jsc
foreach (var item_ in images)
{
var item = item_.Image;
var phase = Math.PI * 2 * i / images.Count + randomphase;
var cos = Math.Cos(step * ms + phase);
var sin = Math.Sin(step * ms + phase);
var z1margin = 0.7;
var z1 = (cos + (1 + z1margin)) / (2 + z1margin);
var z2margin = 1.0;
var z2 = (cos + (1 + z2margin)) / (2 + z2margin);
item.Opacity = z1 * item_.Opacity;
item.SizeTo(size * z2, size * z2);
item.MoveTo(
//.........这里部分代码省略.........
示例8: ApplicationCanvas
public ApplicationCanvas()
{
var c = new CheckBox
{
Content = new TextBlock { Text = "Print to Console " }
}.MoveTo(8, 96);
var t = new TextBlock { Text = "?" }.AttachTo(this);
var redblockcontainer = new Canvas();
redblockcontainer.Opacity = 0.8;
redblockcontainer.Background = Brushes.Red;
redblockcontainer.AttachTo(this);
redblockcontainer.MoveTo(8, 8);
this.SizeChanged += (s, e) => redblockcontainer.MoveTo(64 - 16, this.Height / 3 - 16).SizeTo(this.Width - 96, this.Height / 3 - 8);
var redblockoverlay = new Canvas();
redblockoverlay.Opacity = 0.1;
redblockoverlay.Background = Brushes.Red;
redblockoverlay.AttachTo(this);
redblockoverlay.MoveTo(8, 8);
this.SizeChanged += (s, e) => redblockoverlay.MoveTo(64 + 64, this.Height / 3).SizeTo(this.Width - 96 - 64, this.Height / 3 - 8);
var yellowblock = new Canvas();
yellowblock.Opacity = 0.7;
yellowblock.Background = Brushes.Yellow;
yellowblock.AttachTo(this);
yellowblock.SizeTo(400, 200);
var a_case1 = Enumerable.Range(0, 64).Select(
i =>
{
var rr = new Rectangle();
rr.Fill = Brushes.Blue;
rr.AttachTo(yellowblock);
rr.SizeTo(32, 32);
rr.MoveTo(-32, -32);
return rr;
}
).ToArray();
var a_case2 = Enumerable.Range(0, 64).Select(
i =>
{
var rr = new Rectangle();
rr.Fill = Brushes.Green;
rr.AttachTo(this);
rr.SizeTo(32, 32);
rr.MoveTo(-32, -32);
return rr;
}
).ToArray();
var greenblock = new Canvas();
greenblock.Opacity = 0.5;
greenblock.Background = Brushes.Green;
greenblock.AttachTo(this);
greenblock.SizeTo(400, 200);
greenblock.MoveTo(200 - 12, 12);
var a_case3 = Enumerable.Range(0, 64).Select(
i =>
{
var rr = new Rectangle();
rr.Fill = Brushes.Black;
rr.AttachTo(redblockcontainer);
rr.SizeTo(32, 32);
rr.MoveTo(-32, -32);
return rr;
}
).ToArray();
var case1 = yellowblock;
var case2 = greenblock;
var case3 = redblockoverlay;
#region case1
case1.TouchDown +=
(s, e) =>
{
e.Handled = true;
// is called implicitly on Android Chrome
e.TouchDevice.Capture(case1);
Console.WriteLine("TouchDown");
};
case1.MouseMove +=
(s, e) =>
{
// case 1
var p = e.GetPosition(case1);
//.........这里部分代码省略.........